Adding Prometheus as a Data Source to Grafana

Posted on Tuesday, February 2, 2021


I recently wrote a few article on installing Grafana and Prometheus. [1] [2]

Now that I have it set up and I have prometheus ingesting some data I want to hook it into Promtheus and see some beautiful graphs 

Now I want to start getting some real data into it to have something to graph! 




Adding a Data Source


I have Prometheus and Grafana running on the same box.
Let me ssh into my box and also pull some ports on the way.


  > ssh prometheus -L 3000:localhost:3000 -L 9090:localhost:9090 -L 9100:localhost:9100


Now check if prometheus and grafana are running.


  > sudo systemctl status grafana-server


And Prometheus


  > sudo systemctl status prometheus



OK all looks good.
Now let me open up Grafana.



Click on Configuration and select Data Sources.

Click Add data sources

Click on Select in the Prometheus

Set URL to http://localhost:9090

All other settings leave as is since I have no SSL or anything fancy set up in front of prometheus.


Click on Save & Test

Wahoo its working!

Now go back to Data Sources
Now we should see that we have Promtheus as a data source.


Testing data

First let me prove I have some node exporter data in prometheus.
Head over to http://localhost:9090/graph


 Click on Graph

 Enter node_cpu_seconds_total and click Execute.

 Yeah data

Now back to grafana


Click on + and select Dashboard

Click Add New Panel
Enter the query


(100 - 100*(avg by (node) (irate(node_cpu_seconds_total{mode="idle"}[15m]))))




Then hit apply

On the right scroll down to Axes and set the Y-Min to 0 and Y-Max to 100 and click Apply

As you can see nothing much is going on my CPU is not taxed
On my computer let me run htop to confirm (if you don’t have htop install it with sudo apt-get install htop


  > htop



Now let’s do something to get our CPU to max out or at least jump up a bit.

Let me install and run stress


  > sudo apt-get install stress
   > stress --cpu 2






Run just one cpu



  > stress --cpu 1






[1]        Installing Grafana on Ubuntu 20.04
Accessed 2/2020

[2]        Installing Prometheus on Ubuntu 20.04
Accessed 2/2020




  1. Wow, happy to see this awesome post. I hope this think help any newbie for their awesome work and by the way thanks for share this awesomeness, i thought this was a pretty interesting read when it comes to this topic. Thank you..
    Artificial Intelligence Course

  2. I need to thank you for this very good read and i have bookmarked to check out new things from your post. Thank you very much for sharing such a useful article and will definitely saved and revisit your site.
    Data Science Course

  3. Excellent Blog! I would like to thank you for the efforts you have made in writing this post. Gained lots of knowledge.
    Data Analytics Course

  4. What an incredible message this is. Truly one of the best posts I have ever seen in my life. Wow, keep it up.
    AI Courses in Bangalore

  5. Awesome article. I enjoyed reading your articles. this can be really a good scan for me. wanting forward to reading new articles. maintain the nice work!
    Data Science Courses in Bangalore

  6. I am sure it will help many people. Keep up the good work. It's very compelling and I enjoyed browsing the entire blog.
    Business Analytics Course in Bangalore

  7. I bookmarked your website because this site contains valuable information. I am very satisfied with the quality and the presentation of the articles. Thank you so much for saving great things. I am very grateful for this site.

    Data Science Training in Bangalore

  8. I have voiced some of the posts on your website now, and I really like your blogging style. I added it to my list of favorite blogging sites and will be back soon ...

    Digital Marketing Training in Bangalore

  9. I found Habit to be a transparent site, a social hub that is a conglomerate of buyers and sellers willing to offer digital advice online at a decent cost.

    Artificial Intelligence Training in Bangalore

  10. The Extraordinary blog went amazed by the content that they have developed in a very descriptive manner. This type of content surely ensures the participants explore themselves. Hope you deliver the same near the future as well. Gratitude to the blogger for the efforts.

    Machine Learning Course in Bangalore

  11. Your site is truly cool and this is an extraordinary moving article and If it's not too much trouble share more like that. Thank You..
    Digital Marketing Course in Hyderabad

  12. Thank a lot. You have done excellent job. I enjoyed your blog . Nice efforts
    Data Science Certification in Hyderabad