Public Repository

Last pushed: 3 months ago
Short Description
Grafana and Prometheus together and designed to be fully automated
Full Description

Supported tags and respective Dockerfile links

Versions of components

  • Grafana:4.3.1
  • Prometheus:1.6.3
  • Supervisor

Common for all 'docker run'

  • -e "ENVIRONMENT=<environment_variable>" and -v <path_to_dir_with_prometheus_config_yml>/prometheus-config: These are closely related and are always required as part of the command of all containers. Prometheus in this image relies on a config file matching the environment name i.e. prometheus-local.yml in the container directory /prometheus-config. So if the environment the monitoring is being deployed is prod then -e "ENVIRONMENT=prod" and the config file prometheus-prod.yml must have been mapped to /prometheus-config.

Quick Start

Run with all the options (remove what you don't need)

docker run --name automated-grafana -d -p 9090:9090 -p 6666:6666 \
       -e "ENVIRONMENT=prod" \
       -e "GF_SERVER_HTTP_PORT=6666" \
       -e "WAITING_TIME=20" \
       -v `pwd`/prometheus-config:/prometheus-config \
       -v `pwd`/dashboards:/dashboards \
       -v `pwd`/users:/users \
       -v `pwd`/sources:/sources \
       serragnoli/automated-grafana-prometheus
  • -p 9090:9090: Exposes the Prometheus default port to the host;

  • -p 6666:6666: Exposes a custom Grafana port which was determined by -e "GF_SERVER_HTTP_PORT=6666" so both these parameter values need to match;

  • -e "ENVIRONMENT=prod": This variable determines which Prometheus config to use. Ensure that a prometheus-<env>.yml suffixed with the environment where you'll deploy to exists in the directory. In this example, the value is "prod", /prometheus-config/prometheus-prod.yml is expected to exist;


  • -e "WAITING_TIME=20": By default each json file is loaded 10 seconds apart from each other. There may be situations that 10 seconds may be too much or too little time. When that's the case use this variable to control the interval of loading each json file;

  • -v pwd/dashboards:/dashboards
    -v pwd/users:/users
    -v pwd/sources:/sources
    : Map the directories containing the json files to be loaded by Grafana in the container. It's worth mentioning that the /dashboards directory must only contain dashboard json files and the same applies to the other directories.

After running the above command, you should have Prometheus running on localhost:9090 and Grafana running on localhost:6666


Samples

Dashboard.json Sample

{
    "meta": {
        "type": "db",
        "canSave": true,
        "canEdit": true,
        "canStar": true,
        "slug": "fabs-dashboard",
        "expires": "0001-01-01T00:00:00Z",
        "created": "2017-06-02T22:07:09Z",
        "updated": "2017-06-02T22:07:21Z",
        "updatedBy": "admin",
        "createdBy": "admin",
        "version": 1
    },
    "dashboard": {
        "annotations": {
            "list": []
        },
        "editable": true,
        "gnetId": null,
        "graphTooltip": 0,
        "hideControls": false,
        "links": [],
        "refresh": "5s",
        "rows": [{
            "collapse": false,
            "height": "250px",
            "panels": [{
                "aliasColors": {},
                "bars": false,
                "dashLength": 10,
                "dashes": false,
                "datasource": null,
                "fill": 1,
                "id": 1,
                "legend": {
                    "avg": false,
                    "current": false,
                    "max": false,
                    "min": false,
                    "show": true,
                    "total": false,
                    "values": false
                },
                "lines": true,
                "linewidth": 1,
                "links": [],
                "nullPointMode": "null",
                "percentage": false,
                "pointradius": 5,
                "points": false,
                "renderer": "flot",
                "seriesOverrides": [],
                "spaceLength": 10,
                "span": 12,
                "stack": false,
                "steppedLine": false,
                "targets": [{
                    "expr": "fabio_total_requests",
                    "format": "time_series",
                    "intervalFactor": 2,
                    "metric": "fabio_total_requests",
                    "refId": "A",
                    "step": 2
                }],
                "thresholds": [],
                "timeFrom": null,
                "timeShift": null,
                "title": "Fabs Panel",
                "tooltip": {
                    "shared": true,
                    "sort": 0,
                    "value_type": "individual"
                },
                "type": "graph",
                "xaxis": {
                    "buckets": null,
                    "mode": "time",
                    "name": null,
                    "show": true,
                    "values": []
                },
                "yaxes": [{
                    "format": "short",
                    "label": null,
                    "logBase": 1,
                    "max": null,
                    "min": null,
                    "show": true
                }, {
                    "format": "short",
                    "label": null,
                    "logBase": 1,
                    "max": null,
                    "min": null,
                    "show": true
                }]
            }],
            "repeat": null,
            "repeatIteration": null,
            "repeatRowId": null,
            "showTitle": false,
            "title": "Dashboard Row",
            "titleSize": "h6"
        }],
        "schemaVersion": 14,
        "style": "dark",
        "tags": [],
        "templating": {
            "list": []
        },
        "time": {
            "from": "now-15m",
            "to": "now"
        },
        "timepicker": {
            "refresh_intervals": ["5s", "10s", "30s", "1m", "5m", "15m", "30m", "1h", "2h", "1d"],
            "time_options": ["5m", "15m", "1h", "6h", "12h", "24h", "2d", "7d", "30d"]
        },
        "timezone": "browser",
        "title": "Fabs Dashboard",
        "version": 1
    }
}

Data-Source.json Sample

{
    "orgId": 1,
    "name": "LocalPrometheus",
    "type": "prometheus",
    "typeLogoUrl": "public/app/plugins/datasource/prometheus/img/prometheus_logo.svg",
    "access": "proxy",
    "url": "http://localhost:9090",
    "password": "",
    "user": "",
    "database": "",
    "basicAuth": false,
    "isDefault": true,
    "jsonData": {}
}

Users.json Sample

{
  "name":"Fabs Dashboard Viewer",
  "email":"fabs-dash-viewer@my-org.com",
  "login":"fabs-viewer",
  "password":"fabsviewerpassword"
}
Docker Pull Command
Owner
serragnoli

Comments (0)