DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Related

  • Implementing Real-Time Datadog Monitoring in Deployments
  • Application Integration
  • What Are Events? Process, Data, and Application Integrators
  • Enterprise RIA With Spring 3, Flex 4 and GraniteDS

Trending

  • A Modern Stack for Building Scalable Systems
  • Fraud Detection Using Artificial Intelligence and Machine Learning
  • Beyond ChatGPT, AI Reasoning 2.0: Engineering AI Models With Human-Like Reasoning
  • Testing SingleStore's MCP Server
  1. DZone
  2. Data Engineering
  3. Data
  4. Set Up and Integrate Prometheus With Grafana for Monitoring

Set Up and Integrate Prometheus With Grafana for Monitoring

In this tutorial, we'll learn how to set up and configure Prometheus and Grafana to enable application performance monitoring for REST applications.

By 
Satish Sharma user avatar
Satish Sharma
·
Updated May. 24, 18 · Tutorial
Likes (10)
Comment
Save
Tweet
Share
62.3K Views

Join the DZone community and get the full member experience.

Join For Free

As we know, Prometheus and Grafana can be used to monitor a vast range of applications. In this article, we will learn how to set up Prometheus and Grafana. We will also see how to integrate Prometheus as a data source in Grafana.

For collecting metrics, we shall be targeting the REST application we created in our previous article. This application has exposed a metrics endpoint at "http://localhost:9000/actuator/prometheus" using Spring Boot Actuator.

Note: The steps mentioned in this article are for Windows operating systems. For other environments, the steps may vary.

1. Set Up Prometheus

Download Prometheus distributions for your environment.

Extract the distribution in your selected directory in the file system.

In Prometheus, all configurations are done using configuration files, which are written in YAML format. Prometheus is distributed with a sample configuration file with the name prometheus.yml. You can use this file to configure applications to be monitored or you can create new files. I have created a new file named person-app.yml with the below content:

#Global configurations
global:
  scrape_interval:     5s # Set the scrape interval to every 5 seconds.
  evaluation_interval: 5s # Evaluate rules every 5 seconds.

scrape_configs:
  - job_name: 'person-app'
    metrics_path: '/actuator/prometheus'
    static_configs:
      - targets: ['localhost:9000']


Start the Prometheus server by using the command perometheus.exe --config.file=YAML_FILE_PATH. Image title

Test the server by browsing to the URL http://localhost:9090/. If you are able to see the page below, then you have the Prometheus server running and scraping the metrics for you, which is based on the configuration you made using person-app.yml while starting the server.prometheus home page

2. Set Up Grafana

Download the Grafana distribution for your environment.

Extract the distribution to your file system.

In Grafana, all the configurations are made using ".ini" files, which are placed in the "conf" directory. Grafana is distributed with "defaults.ini" and "sample.ini." You can change/override the configurations (port, security, etc) using this file. For the sake of simplicity, let us proceed with the default settings, which will configure "admin/admin" as the username and password.

Caution: Do not rename the existing or new configuration file as "defaults.ini" unless you are very sure of what properties you are changing and what effects it may have on the server.

The executable to start the server is placed in the "bin" directory of the Grafana distribution. Start the server by executing grafana-server.exe from the bin directory of the distribution.Image title

Log in to Grafana by browsing to http://localhost:3000. The username and password are "admin/admin" (remember that we used the defaults). You can change this anytime using the .ini file we discussed in an earlier step.Image title

3. Add Prometheus as a Data Source in Grafana

Grafana allows you to query, visualize, and alert your metrics from about 30+ open source and commercial data sources. In the next steps, we shall be describing how to add Prometheus as a data source in Grafana.

  • Log into Grafana with the username and password configured (the default is admin/admin).
  • Click the gear icon in the left sidebar and from the menu select "Data Sources." This will list all the configured data sources (if you have configured any).
  • Click on "Add Data Source." This will open a page to add a data source.
    • Give a suitable name to this new data source, as this will be used while creating visualizations. I am using "prometheus-local."
    • Select Prometheus in the "type" drop down.
    • The URL shall be "http://localhost:9090" as we have Prometheus running on local host on port 9090.
    • Fill other details if you have any security or HTTP related settings.
    • Click "Save & Test."
    • If Grafana is able to make connections to Prometheus instance with the details provided, then you will get a message saying "Data source is working." If you get any errors, review your values.Image title

In this article, we have seen how to set up and integrate Prometheus and Grafana. In the next article, we shall be creating a visualization in Grafana that will display the hit count of the API exposed in our REST application.

You can get the person-app.yml file and the application we used for the Prometheus setup from this GitHub repository.

Grafana Integration application Data (computing)

Opinions expressed by DZone contributors are their own.

Related

  • Implementing Real-Time Datadog Monitoring in Deployments
  • Application Integration
  • What Are Events? Process, Data, and Application Integrators
  • Enterprise RIA With Spring 3, Flex 4 and GraniteDS

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!