prometheus #2

Supports: kubernetes

Deploy this charm on Kubernetes with the CLI. Find out how by reading the docs.

Description

Prometheus is an open source monitoring solution. Prometheus supports aggregating high dimensional data and exposes a powerful query language PromQL. This charm deploys and operates Prometheus on Kubernetes clusters. Prometheus can raise alerts through a relation with the Altermanager charm. Alerting rules for Prometheus need to be provided through a relation with the application that requires alerting. Prometheus provides its own dashboard for data visualization but a richer visualization interface may be obtained through a relation with the Grafana charm.


Prometheus Operator

Description

The Prometheus Operator provides a cluster monitoring solution using Prometheus, which is an open source monitoring system and alerting toolkit.

This repository contains a Juju Charm for deploying the monitoring component of Prometheus in a Kubernetes cluster. The alerting component of prometheus is offered through a separate Charm.

Setup

A typical setup using snaps, for deployments to a microk8s cluster can be done using the following commands

sudo snap install microk8s --classic
microk8s.enable dns storage registry dashboard
sudo snap install juju --classic
juju bootstrap microk8s microk8s
juju create-storage-pool operator-storage kubernetes storage-class=microk8s-hostpath

Build

Install the charmcraft tool

sudo snap install charmcraft

Build the charm in this git repository

charmcraft build

Usage

Create a Juju model for your monitoring operators

juju add-model lma

Deploy Prometheus using its default configuration.

juju deploy ./prometheus.charm

View the Prometheus dashboard

  1. Use juju status to determine IP of the Prometheus unit
  2. Navigate to http://<IP-Address>:9090 using your browser

If required, remove the deployed monitoring model completely

juju destroy-model -y lma --no-wait --force --destroy-storage

Relations

Currently supported relations are

Developing

Use your existing Python 3 development environment or create and activate a Python 3 virtualenv

virtualenv -p python3 venv
source venv/bin/activate

Install the development requirements

pip install -r requirements-dev.txt

Testing

Just run run_tests:

./run_tests

Configuration

evaluation-interval
(string) How frequently rules will be evaluated.
1m
external-labels
(string) A JSON string of key-value pairs that specify the labels to attach to metrics in this Prometheus instance when they get pulled by an aggregating parent. This is useful in the case of federation where, for example, you want each datacenter to have its own Prometheus instance and then have a global instance that pulls from each of these datacenter instances. By specifying a unique set of external-labels for each datacenter instance, you can easily determine in the aggregating Prometheus instance which datacenter a metric is coming from. Note that you are not limited to one instance per datacenter. The datacenter example here is arbitrary and you are free to organize your federation's hierarchy as you see fit. Ex. '{ "cluster": "datacenter1" }'. Both keys and values may be arbitrarily chosen as you see fit.
{}
log-level
(string) Prometheus server log level (only log messages with the given severity or above). Must be one of: [debug, info, warn, error, fatal]. If not set, the Prometheus default one (info) will be used.
port
(int) The port prometheus will be listening on
9090
prometheus-image-password
(string) The password associated with prometheus-image-username for accessing the registry specified in prometheus-image-path.
prometheus-image-path
(string) The location of the image to use, e.g. "registry.example.com/prometheus:v1". This setting is required.
prom/prometheus:latest
prometheus-image-username
(string) The username for accessing the registry specified in prometheus-image-path.
scrape-interval
(string) How frequently to scrape targets by default.
1m
scrape-timeout
(string) How long until a scrape request times out.
10s
ssl-cert
(string) SSL certificate to install and use for Prometheus endpoint.
ssl-key
(string) SSL key to use with certificate specified as ssl-cert.
tsdb-retention-time
(string) How long to retain samples in the storage. Units Supported: y, w, d, h, m, s
15d
tsdb-wal-compression
(boolean) This flag enables compression of the write-ahead log (WAL). Depending on your data, you can expect the WAL size to be halved with little extra cpu load.
web-external-url
(string) The URL under which Prometheus is externally reachable (for example, if Prometheus is served via a reverse proxy). Used for generating relative and absolute links back to Prometheus itself. If the URL has a path portion, it will be used to prefix all HTTP endpoints served by Prometheus. If omitted, relevant URL components will be derived automatically.