Giter Club home page Giter Club logo

docker-prometheus-grafana's Introduction

Run Prometheus and Grafana with docker-compose

This project shows how to run Prometheus and Grafana together with Docker Compose. You can use this setup on your workstation to scrape app metrics (disclaimer: this is not production-ready!).

Prerequisites

You only need to install docker-compose on your workstation. If you have Docker Desktop running, docker-compose is already installed.

Make sure this command works:

$ docker-compose version
docker-compose version 1.24.0, build 0aa59064
docker-py version: 3.7.2
CPython version: 3.6.8
OpenSSL version: OpenSSL 1.1.0j  20 Nov 2018

Configuring Prometheus

Edit Prometheus configuration file in prometheus.yml:

global:
  scrape_interval: 10s
  evaluation_interval: 10s

scrape_configs:
- job_name: app1
  scheme: https
  metrics_path: /actuator/prometheus
  static_configs:
    - targets:
      - "app1.cfapps.io"
      labels:
        application: app1

You need to edit the job_name section, according to your app.

For example, if your app is running on your workstation, leveraging Spring Boot and Micrometer, you may end up with this configuration:

- job_name: local
  scheme: http
  metrics_path: /actuator/prometheus
  static_configs:
    - targets:
      - "192.168.0.10:8080"
      labels:
        application: local

Make sure you use your public IP address in case you bind a local app: Prometheus and Grafana are running inside a VM managed by Docker, so you cannot use localhost or 127.0.0.1 for the target address.

If you have several apps to monitor, you can add as many job_name sections as you need. Make sure to use a different job name and an unique application label for each app.

Starting Prometheus/Grafana

You are now ready to start Prometheus and Grafana. Use docker-compose to start these components:

$ docker-compose up --force-recreate

Flag force-recreate is used to erase and recreate new containers with an up-to-date configuration.

Connecting to Grafana

Hit http://localhost:3000: you should see the Grafana login page. Use admin/admin to sign-in.

At this point, a default datasource is running for Prometheus. You just need to create a new dashboard for your apps, by selecting this datasource.

Beware that there is no persistence set for any data: you may loose your configuration when you restart Prometheus/Grafana.

Contribute

Contributions are always welcome!

Feel free to open issues & send PR.

License

Copyright © 2019 Pivotal Software, Inc.

This project is licensed under the Apache Software License version 2.0.

docker-prometheus-grafana's People

Contributors

alexandreroman avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.