mirror of
https://github.com/prometheus-operator/kube-prometheus.git
synced 2025-10-24 21:51:18 +02:00
6.3 KiB
6.3 KiB
title, description, lead, date, lastmod, draft, images, menu, weight, toc
| title | description | lead | date | lastmod | draft | images | menu | weight | toc | ||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Blackbox Exporter | Generated API docs for the Prometheus Operator | This Document documents the types introduced by the Prometheus Operator to be consumed by users. | 2021-03-08T08:49:31+00:00 | 2021-03-08T08:49:31+00:00 | false |
|
630 | true |
Setting up a blackbox exporter
The prometheus-operator defines a Probe resource type that can be used to describe blackbox checks. To execute these, a separate component called blackbox_exporter has to be deployed, which can be scraped to retrieve the results of these checks. You can use kube-prometheus to set up such a blackbox exporter within your Kubernetes cluster.
Adding blackbox exporter manifests to an existing kube-prometheus configuration
- Override blackbox-related configuration parameters as needed.
- Add the following to the list of renderers to render the blackbox exporter manifests:
{ ['blackbox-exporter-' + name]: kp.blackboxExporter[name] for name in std.objectFields(kp.blackboxExporter) }
Configuration parameters influencing the blackbox exporter
_config.namespace: the namespace where the various generated resources (ConfigMap,Deployment,Service,ServiceAccountandServiceMonitor) will reside. This does not affect where you can placeProbeobjects; that is determined by the configuration of thePrometheusresource. This option is shared with otherkube-prometheuscomponents; defaults todefault._config.imageRepos.blackboxExporter: the name of the blackbox exporter image to deploy. Defaults toquay.io/prometheus/blackbox-exporter._config.versions.blackboxExporter: the tag of the blackbox exporter image to deploy. Defaults to the versionkube-prometheuswas tested with._config.imageRepos.configmapReloader: the name of the ConfigMap reloader image to deploy. Defaults tojimmidyson/configmap-reload._config.versions.configmapReloader: the tag of the ConfigMap reloader image to deploy. Defaults to the versionkube-prometheuswas tested with._config.resources.blackbox-exporter.requests: the requested resources; this is used for each container. Defaults to10mCPU and20MiRAM. See https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ for details._config.resources.blackbox-exporter.limits: the resource limits; this is used for each container. Defaults to20mCPU and40MiRAM. See https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ for details._config.blackboxExporter.port: the exposed HTTPS port of the exporter. This is what Prometheus can scrape for metrics related to the blackbox exporter itself. Defaults to9115._config.blackboxExporter.internalPort: the internal plaintext port of the exporter. Prometheus scrapes configured viaProbeobjects cannot access the HTTPS port right now, so you have to specify this port in theurlfield. Defaults to19115._config.blackboxExporter.replicas: the number of exporter replicas to be deployed. Defaults to1._config.blackboxExporter.matchLabels: map of the labels to be used to select resources belonging to the instance deployed. Defaults to{ 'app.kubernetes.io/name': 'blackbox-exporter' }_config.blackboxExporter.assignLabels: map of the labels applied to components of the instance deployed. Defaults to all the labels included in thematchLabelsoption, and additionallyapp.kubernetes.io/versionis set to the version of the blackbox exporter._config.blackboxExporter.modules: the modules available in the blackbox exporter installation, i.e. the types of checks it can perform. The default value includes most of the modules defined in the default blackbox exporter configuration:http_2xx,http_post_2xx,tcp_connect,pop3s_banner,ssh_banner, andirc_banner.icmpis omitted so the exporter can be run with minimum privileges, but you can add it back if needed - see the example below. See https://github.com/prometheus/blackbox_exporter/blob/master/CONFIGURATION.md for the configuration format, except you have to use JSON instead of YAML here._config.blackboxExporter.privileged: whether theblackbox-exportercontainer should be running as non-root (false) or root with heavily-restricted capability set (true). Defaults totrueif you have any ICMP modules defined (which need the extra permissions) andfalseotherwise.
Complete example
local kp =
(import 'kube-prometheus/kube-prometheus.libsonnet') +
{
_config+:: {
namespace: 'monitoring',
blackboxExporter+:: {
modules+:: {
icmp: {
prober: 'icmp',
},
},
},
},
};
{ ['setup/0namespace-' + name]: kp.kubePrometheus[name] for name in std.objectFields(kp.kubePrometheus) } +
{
['setup/prometheus-operator-' + name]: kp.prometheusOperator[name]
for name in std.filter((function(name) name != 'serviceMonitor'), std.objectFields(kp.prometheusOperator))
} +
// serviceMonitor is separated so that it can be created after the CRDs are ready
{ 'prometheus-operator-serviceMonitor': kp.prometheusOperator.serviceMonitor } +
{ ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } +
{ ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } +
{ ['blackbox-exporter-' + name]: kp.blackboxExporter[name] for name in std.objectFields(kp.blackboxExporter) } +
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } +
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) } +
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) }
After installing the generated manifests, you can create Probe resources, for example:
kind: Probe
apiVersion: monitoring.coreos.com/v1
metadata:
name: example-com-website
namespace: monitoring
spec:
interval: 60s
module: http_2xx
prober:
url: blackbox-exporter.monitoring.svc.cluster.local:19115
targets:
staticConfig:
static:
- http://example.com
- https://example.com