prometheus
Prometheus is a monitoring system and time series database.
About this chart
Prometheus
Prometheus, a Cloud Native Computing Foundation project, is a systems and service monitoring system. It collects metrics from configured targets at given intervals, evaluates rule expressions, displays the results, and can trigger alerts if some condition is observed to be true.
TL;DR
$ helm repo add edu https://iac-source.github.io/helm-charts
$ helm repo update
Introduction
This chart bootstraps a Prometheus deployment on a Kubernetes cluster using the Helm package manager.
Prerequisites
- Kubernetes 1.3+ with Beta APIs enabled
Installing the Chart
To install the chart with the release name my-release:
$ helm install --name my-release stable/prometheus
The command deploys Prometheus on the Kubernetes cluster in the default configuration. The configuration section lists the parameters that can be configured during installation.
Tip: List all releases using
helm list
Uninstalling the Chart
To uninstall/delete the my-release deployment:
$ helm delete my-release
The command removes all the Kubernetes components associated with the chart and deletes the release.
Prometheus 2.x
Prometheus version 2.x has made changes to alertmanager, storage and recording rules. Check out the migration guide here
Users of this chart will need to update their alerting rules to the new format before they can upgrade.
Upgrading from previous chart versions.
Version 9.0 adds a new option to enable or disable the Prometheus Server.
This supports the use case of running a Prometheus server in one k8s cluster and scraping exporters in another cluster while using the same chart for each deployment.
To install the server server.enabled must be set to true.
As of version 5.0, this chart uses Prometheus 2.x. This version of prometheus introduces a new data format and is not compatible with prometheus 1.x. It is recommended to install this as a new release, as updating existing releases will not work. See the prometheus docs for instructions on retaining your old data.
Example migration
Assuming you have an existing release of the prometheus chart, named prometheus-old. In order to update to prometheus 2.x while keeping your old data do the following:
-
Update the
prometheus-oldrelease. Disable scraping on every component besides the prometheus server, similar to the configuration below:alertmanager: enabled: false alertmanagerFiles: alertmanager.yml: "" kubeStateMetrics: enabled: false nodeExporter: enabled: false pushgateway: enabled: false server: extraArgs: storage.local.retention: 720h serverFiles: alerts: "" prometheus.yml: "" rules: "" -
Deploy a new release of the chart with version 5.0+ using prometheus 2.x. In the values.yaml set the scrape config as usual, and also add the
prometheus-oldinstance as a remote-read target.prometheus.yml: ... remote_read: - url: http://prometheus-old/api/v1/read ...Old data will be available when you query the new prometheus instance.
Scraping Pod Metrics via Annotations
This chart uses a default configuration that causes prometheus
to scrape a variety of kubernetes resource types, provided they have the correct annotations.
In this section we describe how to configure pods to be scraped;
for information on how other resource types can be scraped you can
do a helm template to get the kubernetes resource definitions,
and then reference the prometheus configuration in the ConfigMap against the prometheus documentation
for relabel_config
and kubernetes_sd_config.
In order to get prometheus to scrape pods, you must add annotations to the the pods as below:
metadata:
annotations:
prometheus.io/scrape: "true"
prometheus.io/path: /metrics
prometheus.io/port: "8080"
spec:
...
You should adjust prometheus.io/path based on the URL that your pod serves metrics from.
prometheus.io/port should be set to the port that your pod serves metrics from.
Note that the values for prometheus.io/scrape and prometheus.io/port must be
enclosed in double quotes.
Configuration
The following table lists the configurable parameters of the Prometheus chart and their default values.
| Parameter | Description | Default |
|---|---|---|
alertmanager.enabled | If true, create alertmanager | true |
alertmanager.name | alertmanager container name | alertmanager |
alertmanager.image.repository | alertmanager container image repository | prom/alertmanager |
alertmanager.image.tag | alertmanager container image tag | v0.21.0 |
alertmanager.image.pullPolicy | alertmanager container image pull policy | IfNotPresent |
alertmanager.prefixURL | The prefix slug at which the server can be accessed | `` |
alertmanager.baseURL | The external url at which the server can be accessed | "http://localhost:9093" |
alertmanager.extraArgs | Additional alertmanager container arguments | {} |
alertmanager.extraSecretMounts | Additional alertmanager Secret mounts | [] |
alertmanager.configMapOverrideName | Prometheus alertmanager ConfigMap override where full-name is {{.Release.Name}}-{{.Values.alertmanager.configMapOverrideName}} and setting this value will prevent the default alertmanager ConfigMap from being generated | "" |
alertmanager.configFromSecret | The name of a secret in the same kubernetes namespace which contains the Alertmanager config, setting this value will prevent the default alertmanager ConfigMap from being generated | "" |
alertmanager.configFileName | The configuration file name to be loaded to alertmanager. Must match the key within configuration loaded from ConfigMap/Secret. | alertmanager.yml |
alertmanager.ingress.enabled | If true, alertmanager Ingress will be created | false |
alertmanager.ingress.annotations | alertmanager Ingress annotations | {} |
alertmanager.ingress.extraLabels | alertmanager Ingress additional labels | {} |
alertmanager.ingress.hosts | alertmanager Ingress hostnames | [] |
alertmanager.ingress.extraPaths | Ingress extra paths to prepend to every alertmanager host configuration. Useful when configuring custom actions with AWS ALB Ingress Controller | [] |
alertmanager.ingress.tls | alertmanager Ingress TLS configuration (YAML) | [] |
alertmanager.nodeSelector | node labels for alertmanager pod assignment | {} |
alertmanager.tolerations | node taints to tolerate (requires Kubernetes >=1.6) | [] |
alertmanager.affinity | pod affinity | {} |
alertmanager.podDisruptionBudget.enabled | If true, create a PodDisruptionBudget | false |
alertmanager.podDisruptionBudget.maxUnavailable | Maximum unavailable instances in PDB | 1 |
alertmanager.schedulerName | alertmanager alternate scheduler name | nil |
alertmanager.persistentVolume.enabled | If true, alertmanager will create a Persistent Volume Claim | true |
alertmanager.persistentVolume.accessModes | alertmanager data Persistent Volume access modes | [ReadWriteOnce] |
alertmanager.persistentVolume.annotations | Annotations for alertmanager Persistent Volume Claim | {} |
alertmanager.persistentVolume.existingClaim | alertmanager data Persistent Volume existing claim name | "" |
alertmanager.persistentVolume.mountPath | alertmanager data Persistent Volume mount root path | /data |
alertmanager.persistentVolume.size | alertmanager data Persistent Volume size | 2Gi |
alertmanager.persistentVolume.storageClass | alertmanager data Persistent Volume Storage Class | unset |
alertmanager.persistentVolume.volumeBindingMode | alertmanager data Persistent Volume Binding Mode | unset |
alertmanager.persistentVolume.subPath | Subdirectory of alertmanager data Persistent Volume to mount | "" |
alertmanager.podAnnotations | annotations to be added to alertmanager pods | {} |
alertmanager.podLabels | labels to be added to Prometheus AlertManager pods | {} |
alertmanager.podSecurityPolicy.annotations | Specify pod annotations in the pod security policy | {} |
alertmanager.replicaCount | desired number of alertmanager pods | 1 |
alertmanager.statefulSet.enabled | If true, use a statefulset instead of a deployment for pod management | false |
alertmanager.statefulSet.podManagementPolicy | podManagementPolicy of alertmanager pods | OrderedReady |
alertmanager.statefulSet.headless.annotations | annotations for alertmanager headless service | {} |
alertmanager.statefulSet.headless.labels | labels for alertmanager headless service | {} |
alertmanager.statefulSet.headless.enableMeshPeer | If true, enable the mesh peer endpoint for the headless service | false |
alertmanager.statefulSet.headless.servicePort | alertmanager headless service port | 80 |
alertmanager.priorityClassName | alertmanager priorityClassName | nil |
alertmanager.resources | alertmanager pod resource requests & limits | {} |
alertmanager.securityContext | Custom security context for Alert Manager containers | {} |
alertmanager.service.annotations | annotations for alertmanager service | {} |
alertmanager.service.clusterIP | internal alertmanager cluster service IP | "" |
alertmanager.service.externalIPs | alertmanager service external IP addresses | [] |
alertmanager.service.loadBalancerIP | IP address to assign to load balancer (if supported) | "" |
alertmanager.service.loadBalancerSourceRanges | list of IP CIDRs allowed access to load balancer (if supported) | [] |
alertmanager.service.servicePort | alertmanager service port | 80 |
alertmanager.service.sessionAffinity | Session Affinity for alertmanager service, can be None or ClientIP | None |
alertmanager.service.type | type of alertmanager service to create | ClusterIP |
alertmanager.strategy | Deployment strategy | { "type": "RollingUpdate" } |
alertmanagerFiles.alertmanager.yml | Prometheus alertmanager configuration | example configuration |
configmapReload.prometheus.enabled | If false, the configmap-reload container for Prometheus will not be deployed | true |
configmapReload.prometheus.name | configmap-reload container name | configmap-reload |
configmapReload.prometheus.image.repository | configmap-reload container image repository | jimmidyson/configmap-reload |
configmapReload.prometheus.image.tag | configmap-reload container image tag | v0.3.0 |
configmapReload.prometheus.image.pullPolicy | configmap-reload container image pull policy | IfNotPresent |
configmapReload.prometheus.extraArgs | Additional configmap-reload container arguments | {} |
configmapReload.prometheus.extraVolumeDirs | Additional configmap-reload volume directories | {} |
configmapReload.prometheus.extraConfigmapMounts | Additional configmap-reload configMap mounts | [] |
configmapReload.prometheus.resources | configmap-reload pod resource requests & limits | {} |
configmapReload.alertmanager.enabled | If false, the configmap-reload container for AlertManager will not be deployed | true |
configmapReload.alertmanager.name | configmap-reload container name | configmap-reload |
configmapReload.alertmanager.image.repository | configmap-reload container image repository | jimmidyson/configmap-reload |
configmapReload.alertmanager.image.tag | configmap-reload container image tag | v0.3.0 |
configmapReload.alertmanager.image.pullPolicy | configmap-reload container image pull policy | IfNotPresent |
configmapReload.alertmanager.extraArgs | Additional configmap-reload container arguments | {} |
configmapReload.alertmanager.extraVolumeDirs | Additional configmap-reload volume directories | {} |
configmapReload.alertmanager.extraConfigmapMounts | Additional configmap-reload configMap mounts | [] |
configmapReload.alertmanager.resources | configmap-reload pod resource requests & limits | {} |
initChownData.enabled | If false, don't reset data ownership at startup | true |
initChownData.name | init-chown-data container name | init-chown-data |
initChownData.image.repository | init-chown-data container image repository | busybox |
initChownData.image.tag | init-chown-data container image tag | latest |
initChownData.image.pullPolicy | init-chown-data container image pull policy | IfNotPresent |
initChownData.resources | init-chown-data pod resource requests & limits | {} |
kubeStateMetrics.enabled | If true, create kube-state-metrics sub-chart, see the kube-state-metrics chart for configuration options | true |
kube-state-metrics | kube-state-metrics configuration options | Same as sub-chart's |
nodeExporter.enabled | If true, create node-exporter | true |
nodeExporter.name | node-exporter container name | node-exporter |
nodeExporter.image.repository | node-exporter container image repository | prom/node-exporter |
nodeExporter.image.tag | node-exporter container image tag | v1.0.1 |
nodeExporter.image.pullPolicy | node-exporter container image pull policy | IfNotPresent |
nodeExporter.extraArgs | Additional node-exporter container arguments | {} |
nodeExporter.extraInitContainers | Init containers to launch alongside the node-exporter | [] |
nodeExporter.extraHostPathMounts | Additional node-exporter hostPath mo |
Deploy prometheus with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has prometheus on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartprometheus is pinned at v11.6.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply