There are a variety of instruments used to measure wind direction, such as the windsock and wind vane. Both of these instruments work by moving to minimize air resistance. The way they are pointed by prevailing winds indicates the direction from which the wind is blowing.
Modern instruments, called electronic anemometers measure wind direction in a similar fashion but contain electronics to translate directional data from the vane into formats which computers can interpret. Many of these instruments measure wind speed as well. Although you can measure the wind direction by observing too.