Prometheus Scrape Config Generator
Build Prometheus scrape YAML from target rows and labels with timing, grouping, limits and validation cues to review before a live reload.team=platform,env=prod.static_configs entry.sample_limit.target_limit.label_limit.{{ values.scrape_yaml }}
| Target | Labels | Overrides | Static group | Copy |
|---|---|---|---|---|
{{ row.target }} | {{ row.labels || '—' }} | {{ row.overrides || '—' }} | {{ row.group }} |
| Level | Check | Detail | Recommendation | Copy |
|---|---|---|---|---|
| {{ row.level }} | {{ row.check }} | {{ row.detail }} | {{ row.recommendation }} |
A dashboard can be empty even when an exporter is healthy. Prometheus only receives those metrics when a scrape job names a reachable target and uses the correct scheme, path, timing, and labels. The configuration is therefore part inventory, part request policy, and part data model.
A scrape job normally represents one class of endpoint, such as node exporters or application metrics. Prometheus polls each target at the configured interval, waits no longer than the timeout, and attaches labels that later drive queries, alerts, and ownership. A stable job name matters because it becomes the default job label on scraped series.
- Target
- The host and optional port Prometheus contacts. The protocol and metrics path are separate settings.
- Static config
- A group of targets that share one label set. It suits known inventories; dynamic environments often need service discovery instead.
- Scrape interval
- How often a scrape starts. Shorter intervals improve resolution but increase traffic, parsing, and storage work.
- Scrape timeout
- How long one scrape may run. It cannot be greater than the scrape interval.
Labels should describe stable dimensions that operators will actually query, such as site, environment, or role. Inconsistent spelling splits what should be one group; volatile labels can multiply time-series cardinality. Per-target overrides are useful when a small number of endpoints need a different scheme, path, interval, timeout, or request parameter, but they also make a job harder to review.
Generated YAML is not proof that a running server will accept or successfully use the job. It still has to be placed in the correct configuration scope, checked with the deployed Prometheus tooling, reloaded, and observed through the targets view or the up metric. Network reachability, TLS, authentication, exporter response time, and relabeling remain outside a static generator's view.
How to Use This Tool:
Start from endpoints that Prometheus can reach, then add only the labels and overrides needed for that job.
- Enter a stable Job name, choose HTTP or HTTPS, and set the slash-prefixed Metrics path.
- Set Scrape interval and Scrape timeout with Prometheus duration syntax such as
30sand10s. Correct the timeout if it exceeds the interval. - Paste one
host:porttarget per line. Add labels after the address assite=dc1orrole=node; blank lines and lines beginning with#are ignored. - Add Common labels only when every target needs them. Turn on Group identical label sets to combine targets whose complete label maps match exactly.
- Use Honor scraped labels only when target-provided labels must win conflicts, such as a deliberate federation or Pushgateway workflow. A zero sample, target, or label limit omits that setting from the YAML.
- Review Target ledger for duplicates and per-target overrides, then check Validation review. Copy the full block for a standalone snippet or the job item when inserting it under an existing
scrape_configslist.
Interpreting Results:
A parsed target count and a Pass timing check show that the row syntax and local rules are coherent. Repeated addresses, label-conflict overrides, and per-target request overrides produce review findings because they may be intentional but deserve an operator decision.
The runtime-validation finding always remains until the final configuration is checked outside the generator. Run promtool check config on the complete file, reload Prometheus through the method enabled in your deployment, and verify that each expected target appears and reports up = 1.
Technical Details:
A Prometheus static scrape configuration maps job defaults and target-specific label maps into one or more static_configs entries. The transformation is textual, but correctness depends on ordered validation rules rather than a numeric formula.
Transformation Core
| Input form | Normalized meaning | Generated YAML |
|---|---|---|
host:port | Target address | An item under targets |
key=value | Static label attached to that target | An entry under the group's labels |
scheme=https | Per-target scheme override | __scheme__: 'https' |
path=/custom | Per-target metrics-path override | __metrics_path__: '/custom' |
interval=15s or timeout=5s | Per-target timing override | __scrape_interval__ or __scrape_timeout__ |
param_module=http_2xx | First value for a request parameter | __param_module__: 'http_2xx' |
Common labels are applied first and a target row can replace a common value with the same name. With grouping disabled, every target becomes its own static group. With grouping enabled, complete label maps are sorted for comparison and only exact matches share a group.
Rule Core
| Field | Accepted rule | Boundary |
|---|---|---|
| Duration | Positive whole-number units may be combined in the order years, weeks, days, hours, minutes, seconds, milliseconds. | Timeout must be less than or equal to interval; zero is not a valid interval or timeout. |
| Target | Non-empty host or host:port without a URL scheme, whitespace, or path. | At most 500 parsed targets and 200,000 source characters. |
| Label name | Starts with a letter or underscore, then uses letters, digits, or underscores. | Blank values are rejected. |
| Metrics path | Starts with / and contains no whitespace. | The same rule applies to a per-target path override. |
| Limits | Whole numbers from 0 through 1,000,000,000. | Zero omits the corresponding YAML key; positive values emit it. |
Generated scalars are single-quoted, and an embedded apostrophe is doubled for YAML safety. honor_labels is emitted only when true because false is the Prometheus default. honor_timestamps is emitted only when false because true is the default.
Duplicate review compares target addresses, not full label maps. Two equal addresses with different labels therefore remain separate rows and still produce a duplicate finding. That may be legitimate, but it can also create multiple scrapes of the same endpoint.
Limitations and Privacy Notes:
The generator does not contact targets, parse the output with a Prometheus server, validate TLS or authentication, estimate cardinality, or confirm that a reload succeeded. Treat the YAML as a reviewable draft. Target names, labels, and internal hostnames remain in the browser during generation, but copied or downloaded artifacts contain them in plain text and should be handled like other infrastructure configuration.
Worked Examples:
Two node exporters in one group
Two targets use site=dc1,role=node with grouping enabled. Their complete label maps match, so one static_configs item contains both addresses and one shared labels map. With grouping disabled, the same inputs produce two static items.
One application needs HTTPS
A job defaults to HTTP and /metrics, while one target row adds scheme=https path=/actuator/prometheus timeout=5s. Those values become special per-target labels. The validation review calls them out so the operator can confirm that the exception is deliberate before reload.
References:
- Configuration, Prometheus Authors.
- promtool, Prometheus Authors.
- How to add a Prometheus scrape config, Simplified Guide.
- How to reload Prometheus configuration, Simplified Guide.