• This repository has been archived on 07/Oct/2021
  • Stars
    star
    113
  • Rank 310,115 (Top 7 %)
  • Language
  • Created almost 9 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Easy to follow guide on how to deploy and make the best use of the Rancher community catalog template for Prometheus.

Monitoring Guide - Prometheus/Grafana/Rancher

An easy to follow guide on deploying and making the best use of the Rancher community catalog template for Prometheus. Updated for Rancher 1.5.5+ and catalog entry version 3.0.0

Screens

Objectives

Over the last few years, the quality of products available to monitor your systems and services has increased dramatically. The adoption of technologies such as Docker has enabled us to lower the barrier for running these cool new technologies.

With this in mind, I put together this auto-discovering monitoring platform to demonstrate what can be done, and to get people using these great products. The solution is built around monitoring a Docker environment under the control of Rancher. If your not familiar with Rancher then i'd recommend checking out their website for more information.

Rancher provides a community catalog where people can submit example technology stacks that allow people to get up and running within minutes. I've chosen to leverage this and have submitted this build as a pull-request to Rancher for incoporation into their catalog.

All that aside, it's been a cool personal project to work on, and gives me an opportunity to contribute back to the community that supports us all.

Technologies

In this catalog item, the following technologies are utilised to make this as useful as possible;

  • Prometheus - Used to scrape and store metrics from our data sources.
  • Prometheus Node Exporter - Gets host level metrics and exposes them to Prometheus.
  • cAdvisor - Deploys and Exposes the cadvsior stats used by Rancher's agent container, to Prometheus.
  • Grafana - Used to visualise the data from Prometheus and InfluxDB.
  • Prometheus Rancher Exporter - Allows Prometheus to access the Rancher API and return the status of any stack or service in the rancher environment associated with the API key used.

Deployment

Pre-Requisites

This template will work out of the box to give you host and container monitoring through numerous sources. If you also wish to monitor the Rancher server its-self, prometheus metrics need enabling for the server instance. Details on how to do this are listed below.

Deployment Steps:

  1. Select Prometheus from the community catalog.
  2. Enter the IP Address of your Rancher server (used for accessing Ranchers own metrics, optional)
  3. Click deploy.

Usage

Once deployed, all the services should be green in Rancher and your new monitoring platform should be ready to use! Depending upon your specific implementation, you may need to open up the firewall for ports 9090 for Prometheus and 3000 for Grafana.

  • Prometheus will now be available, running on port 9090. Have a play around with some of the data. For more information on Prometheus, check out their documentation.
  • Grafana will now be available, running on port 3000. I've added a number of dashboards to help get you started. Authenticate with the default admin/admin account and password

Alerting

Depending on preference, Alerting can be achieved through making use of Prometheus's alert-manager service, or through Grafana's own alerting capability. Alerts are a very bespoke output in most cases, as such i've not attempted to pre-bake anything into this guide or catalog item. The good news however is that both are good solutions and can be configured easily.

Enabling Prometheus metrics for the Rancher Server

  1. Set the environment variable CATTLE_PROMETHEUS_EXPORTER to true for the Rancher server container.
  2. Expose the metric port on the container as such -p 9108:9108 so that prometheus can scrape the container

With those commands in-mind, starting a rancher server looks something akin to this:

sudo docker run -d --restart=unless-stopped -e CATTLE_PROMETHEUS_EXPORTER=true -p 8080:8080 -p 9108:9108 rancher/server

How is it Done?

API Integration

We use API keys so that we can query Rancher over it's API for service/stack/host status's, an example of this is through the Prometheus Dashboard in Grafana. The actual process doing this is called the prometheus-rancher-exporter.

To provide access to the API, We make use of the following lables in Rancher:

      io.rancher.container.create_agent: true
      io.rancher.container.agent.role: environment

This API interaction means you can easily build service/stack status graphs for your key applications and expose them to a wider audience without needing to give them access to Rancher itsself.

Troubleshooting

Expected Data is missing?

First, load up Prometheus on port 9090 and click on the status page at the top. This should show you the scrape status of all of your end-points. If everything looks good there, have a look at grafana and perform a test of it's data sources to ensure connectivity is there.

Rancher Server Metrics aren't showing in Grafana?

Have you followed the steps listed for 'Enabling Prometheus metrics for the Rancher Server'? If so, you might want to check that your mapping through the port correctly.

Acknowledgements

  • James Barwell - For all his efforts first introducing me to Prometheus and for the original rancher-api integration.
  • Jolyon Brown - For his efforts in adding in further functionality to the API integration.
  • Rancher Labs - For providing awesome support and details on how to effectivley montior Rancher server.

And of course, all the guys behind Prometheus/Grafana for making such great tools.

More Repositories

1

prometheus-example-queries

Simple place for people to provide examples of queries they've found useful.
857
star
2

github-exporter

:octocat: Prometheus exporter for github metrics
Go
343
star
3

prometheus-rancher-exporter

Exposes Rancher metrics to Prometheus
Go
99
star
4

docker-hub-exporter

Prometheus exporter for the Docker Hub
Go
76
star
5

101-Sessions

Documentation and support material for IW 101 Sessions
JavaScript
52
star
6

hpilo-exporter

Prometheus HP iLO exporter
Python
47
star
7

snow-cannon

An infrastructure as code approach to deploying Snowflake using Terraform
HCL
23
star
8

gar-exporter

Google Analytics Reporting API V4
Python
16
star
9

music

A REST api demo project that generates sequence diagrams from tests
Go
13
star
10

moby-container-stats

Prometheus Exporter - container stats exposed directly from the moby stats API
Go
12
star
11

docker-cloud-exporter

Prometheus Exporter for Docker Cloud
Go
8
star
12

graf-db

Pre-Configured data container for Grafana dashboards based upon Prometheus & Rancher.
8
star
13

prom-conf

Prometheus config container
7
star
14

terraform-canary

HCL
7
star
15

data-academy-serverless-example

A repository to demonstrate a simple serverless repo for the data academy.
Shell
7
star
16

ranch-eye

Simple container stats using Rancher as the source.
6
star
17

serverless

Serverless Application Template
JavaScript
6
star
18

kubehack

Kubernetes Hack Night
5
star
19

iw-tech-test

Infinity Works Tech Test - Starter Projects
Java
4
star
20

academy-tech-test

Python
4
star
21

iw-tech-test-py

Infinity Works Tech Test - Python Starter Project
Python
4
star
22

iw-data-test-python

Infinity Works Data Test - Starter Project
Python
4
star
23

generation-academy-tech-test

A sample tech test repo for the Generation Data Academy
Python
4
star
24

data-academy-cloudformation-example

A repository to demonstrate a simple CloudFormation repo for the data academy.
Python
3
star
25

iw-tech-test-dotnet

Infinity Works Tech Test - Starter Projects for .NET Core
C#
3
star
26

iw-data-test-python-pandas

Python
3
star
27

iw-tech-test-terraform-azure

Technical test for Engineers using azure terraform
Shell
3
star
28

aws-decryption-go

Decrypt AWS Encryption SDK formatted blobs using a custom private key
Go
2
star
29

iw-tech-test-platform

Infinity Works Platform Tech Test
Makefile
2
star
30

autovault

This project generates a raw vault model from metadata
Python
2
star
31

iw-tech-test-snowflake

Python
2
star
32

sample-jenkins-pipeline-job

Java
2
star
33

Bamboo-api-exporter

Open source toolkit for exporting data via bambooHR's API
Python
2
star
34

pact-demo

An example repo that shows a consumer of an api and the provider of that API being integrated with a locally hosted Pact Broker.
TypeScript
2
star
35

rsgo

ReadySteadyGo
2
star
36

email-signature-generator

A simple email signature generator
HTML
2
star
37

node-app-base

Basic utilities for running node microservices
JavaScript
2
star
38

awscli-terraform-snowflake

A docker image containing awscli, terraform and snowflake
Dockerfile
2
star
39

snailx_api

SnailX external team API.
Python
1
star
40

snailx_dev_env

Development environment repo for SnailX external team.
Makefile
1
star
41

iw-tech-test-terraform

Dockerfile
1
star
42

spike-aws-batch

Go
1
star
43

javascript-academy-tech-test

HTML
1
star
44

iw-tech-test-nodejs

Infinity Works Node.js Engineering Tech Test
JavaScript
1
star
45

go-workshop-practical

Go
1
star
46

go-common

Some small common go libs and utils
Go
1
star
47

bamboo-contact-sheet

A quick and dirty way to create an office contact sheet from Bamboo HR
Python
1
star
48

aws-sso-google-sync

Populate AWS SSO directly with your G Suite users and groups using either a CLI or AWS Lambda
Go
1
star
49

amazon-connect-flow-sync

Automated syncing of contact flows between a local directory and an amazon connect instance
JavaScript
1
star