A customer pumps gasoline into his car at a service station in San Francisco. Getty Images

Global investment in energy fell for a second consecutive year in 2016, and an international watchdog is ringing alarm bells about future shortages of oil and electricity. Energy companies and investors last year plowed $1.7 trillion into fossil fuel exploration, new power plants, upgrades to the electric grid and all the other means of powering the world, the International Energy Agency reported Tuesday. That marks a 12 percent drop from 2015, IEA said in its annual World Energy Investment report. The decline was largely driven by falling oil and gas spending during the second full year of a punishing crude price downturn, as well as falling investment in power generation, particularly from coal plants. The declining investment won't have much affect in the coming years because the world is oversupplied with oil and some global markets can produce more electricity than they use. However, "falling investment points to a risk of market tightness and undercapacity at some point down the line," according to IEA, which advises the international community on energy policy.

Trouble in the oil patch

Investment in oil and gas exploration and production fell by 26 percent to $650 billion in 2016. To be sure, falling costs in the industry account for most of the decline, but IEA warns that a drop in drilling activity also played a major role. That's a problem because oil companies need to continually drill new wells to replace declining production from existing wells. The drop in new production threatens to leave the world with too little oil to meet demand, which has historically pushed up oil prices.

"The recent spectacular decline in upstream oil and gas investment raises major concerns about the prospects for the adequacy of supply in the years to come," IEA said. "There is no doubt that current upstream investment is not sufficient to cover the medium-term growth in oil demand given the outlook for macroeconomic factors and current government policies" that the IEA previously laid out in an annual report. IEA expects an uptick in production from U.S. shale formations, which requires expensive advanced drilling methods and accounted for much of the drop in investment last year. However, IEA warns that growth in shale oil output won't be enough to offset declining output from conventional oil fields, which provide the bulk of the world's supply. Oil companies made final investment decisions on about 50 conventional oil projects in 2016, down 70 percent from 2013. Discoveries of conventional oil fell to 2.4 billion barrels, half the level of 2015, when drillers made the fewest new discoveries since 1952.

Electricity needs to be 'flexible'

The world invested $720 billion in the electricity sector in 2016, the first time spending outpaced oil and gas financing but still a 1 percent drop from 2015. Spending on the network that delivers electricity to users, like transmission wires, increased as utilities continued to modernize the grid and update it to accommodate renewable energy. But investment in power generation fell 5 percent, driven largely by lower spending on coal-fired plants, offsetting network spending.