From b12ed54f951bed9e750df1ef955305b5839c2c72 Mon Sep 17 00:00:00 2001 From: Timo Beckers Date: Thu, 25 Oct 2018 17:52:43 +0200 Subject: [PATCH 1/2] documentation - add marathon-sd example configuration Signed-off-by: Timo Beckers --- .../examples/prometheus-marathon.yml | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 documentation/examples/prometheus-marathon.yml diff --git a/documentation/examples/prometheus-marathon.yml b/documentation/examples/prometheus-marathon.yml new file mode 100644 index 000000000..417a05358 --- /dev/null +++ b/documentation/examples/prometheus-marathon.yml @@ -0,0 +1,60 @@ +# A example scrape configuration for running Prometheus on a Marathon +# (or DC/OS) cluster. + +scrape_configs: + + # Make Prometheus scrape itself for metrics. + - job_name: 'prometheus' + static_configs: + - targets: ['localhost:9090'] + + # Discover Marathon services to scrape. + - job_name: 'marathon' + + # Scrape Marathon itself to discover new services every minute. + marathon_sd_configs: + - servers: + - http://marathon.mesos:8080 + refresh_interval: 60s + + relabel_configs: + + # Only scrape targets that have a port label called 'metrics' specified on a port + # in their app definitions. Example using a port mapping (container or bridge networking): + # + # "portMappings": [ + # { + # "containerPort": 9091, + # "name": "prometheus", + # "labels": { + # "metrics": "/metrics" + # } + # } + # ] + # + # Or, in case your service uses host networking, using a port definition: + # + # "portDefinitions" : [ + # { + # "port" : 9091, + # "name" : "prometheus", + # "labels": { + # "metrics": "/metrics" + # } + # } + # ] + + # Match a slash-prefixed string either in a portMapping or a portDefinition label. + - source_labels: [__meta_marathon_port_mapping_label_metrics,__meta_marathon_port_definition_label_metrics] + regex: (\/.+;|;\/.+) + action: keep + + # If a portMapping 'metrics' label is set, use the label value as the URI to scrape. + - source_labels: [__meta_marathon_port_mapping_label_metrics] + regex: (\/.+) + target_label: __metrics_path__ + + # If a portDefinition 'metrics' label is set, use the label value as the URI to scrape. + - source_labels: [__meta_marathon_port_definition_label_metrics] + regex: (\/.+) + target_label: __metrics_path__ From 36143be2349f414623a45ffe6143bc9ae71cb4d4 Mon Sep 17 00:00:00 2001 From: Timo Beckers Date: Thu, 25 Oct 2018 17:56:19 +0200 Subject: [PATCH 2/2] docs - refer to documentation/examples/prometheus-marathon.yml Signed-off-by: Timo Beckers --- docs/configuration/configuration.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/configuration/configuration.md b/docs/configuration/configuration.md index caf54fd76..0dcee5158 100644 --- a/docs/configuration/configuration.md +++ b/docs/configuration/configuration.md @@ -874,8 +874,12 @@ tls_config: By default every app listed in Marathon will be scraped by Prometheus. If not all of your services provide Prometheus metrics, you can use a Marathon label and -Prometheus relabeling to control which instances will actually be scraped. Also -by default all apps will show up as a single job in Prometheus (the one specified +Prometheus relabeling to control which instances will actually be scraped. +See [the Prometheus marathon-sd configuration file](/documentation/examples/prometheus-marathon.yml) +for a practical example on how to set up your Marathon app and your Prometheus +configuration. + +By default, all apps will show up as a single job in Prometheus (the one specified in the configuration file), which can also be changed using relabeling. ### ``