Prometheus Scrape Config Generator
Generate Prometheus scrape YAML from targets, labels, timing, and limits, then check grouping, overrides, and audit warnings before reload.{{ analysis.yaml }}
| Target | Label count | Labels | Overrides | Static group | Copy |
|---|---|---|---|---|---|
| {{ row.target }} | {{ row.labelCount }} | {{ row.labels }} | {{ row.overrides }} | {{ row.group }} |
| Severity | Check | Finding | Action | Copy |
|---|---|---|---|---|
| {{ row.severity }} | {{ row.check }} | {{ row.finding }} | {{ row.action }} |
Introduction:
Many Prometheus problems surface as missing dashboards, noisy alerts, or unexplained gaps in a time series, but the first cause is often the scrape job. A scrape job tells Prometheus which endpoints to poll, how often to poll them, which HTTP path to request, and what labels should travel with the samples. Those choices decide whether a metric can be queried by team, site, role, environment, or instance after it lands in storage.
Prometheus can discover targets dynamically from systems such as Kubernetes, cloud providers, and service-discovery files, but static scrape configuration still matters. Static target groups are common for small exporter fleets, lab systems, edge devices, network appliances, dedicated application endpoints, and controlled rollouts where the inventory is known before deployment. The operational risk is reviewability: hand-written YAML can hide duplicate targets, misplaced labels, excessive label variation, too-short timeouts, and paths that belong on only one endpoint.
| Choice | Why It Matters | Common Mistake |
|---|---|---|
| Job name | Becomes the default job label for scraped series. |
Using a temporary name that later breaks alerts or dashboard filters. |
| Target address | Identifies the host and optional port that Prometheus contacts. | Putting a protocol prefix into the target instead of using a separate scheme. |
| Labels | Add stable metadata for grouping, ownership, routing, and queries. | Adding high-cardinality or inconsistent labels that make queries and storage harder to control. |
| Interval and timeout | Set the scrape cadence and the maximum time Prometheus waits for a response. | Making the timeout longer than the interval, or setting a cadence faster than exporters can handle. |
A useful static job separates three ideas that are easy to mix together: the address Prometheus dials, the labels that describe the target, and the scrape behavior that may differ for one endpoint. For example, two node exporters might share the same path and interval, while one application target needs HTTPS, a custom metrics path, and a shorter timeout. Keeping those differences explicit prevents a broad job default from quietly applying to the wrong endpoint, and it makes later review easier when an alert depends on a label such as site or role.
Generated YAML should still be treated as operational configuration, not as proof that monitoring works. Prometheus can reject malformed reloads, exporters can fail to respond, and labels that look harmless in a small sample can create expensive cardinality at scale. A good scrape config is therefore both syntactically valid and easy for another operator to review before it reaches a running Prometheus server.
How to Use This Tool:
Build the job defaults first, then add targets and use the result tables to catch mistakes before copying the YAML into a larger Prometheus configuration.
- Enter a stable
Job name. Choose the label value you want Prometheus to attach to the job by default, such asnode-exporters,network-devices, orapplication-api. - Set
Scheme,Metrics path,Scrape interval, andScrape timeout. The path must start with/, and the timeout must be less than or equal to the interval. - Add
Targets and labels, one target per line. Put thehost:portvalue first, then addlabel=valuepairs separated by commas or spaces. Lines beginning with#are ignored. - Use row-specific scrape overrides only when one endpoint differs from the job defaults. Accepted aliases include
scheme=https,path=/custom,interval=15s,timeout=5s, and URL parameter labels such asparam_module=http_2xx. - Open
Advancedwhen you need a job item instead of a fullscrape_configsblock, common labels for every target, grouped static configs, honor-label or timestamp behavior, or sample, target, and label limits. - If
Scrape config needs attentionappears, fix the listed issue before using the result. Common fixes include removing protocol text from a target, correcting a label name, making a duration positive, or loweringScrape timeout. - Review
Scrape YAML,Target Ledger, andConfig Audit. Copy the YAML only after the ledger shows the intended labels and overrides for every target.
Use the sample data when you want to see the accepted row format, including comma labels, whitespace labels, comments, and a target with custom HTTPS/path/timeout behavior.
Interpreting Results:
Scrape config ready means the entered values passed the generator's local checks and produced structured YAML. It does not mean the final Prometheus file is valid in its full context, the endpoints are reachable, or the exporters return metrics successfully.
Check the Scrape YAML first for the job name, path, scheme, interval, timeout, and static target groups you expect. Then use Target Ledger to confirm each target's visible labels, internal scrape overrides, and static group. Config Audit is the compact review list for duplicate targets, timeout budget, grouping, overrides, and active scrape limits.
- Run
promtool check configagainst the complete Prometheus file before reload, not just the generated job fragment. - After reload, check Prometheus target status to confirm reachability, HTTP status, scrape duration, and sample counts.
- Treat duplicate targets and per-target override labels as review flags even when YAML generation succeeds.
- Use nonzero sample, target, and label limits carefully because a scrape can fail when an exporter exceeds the cap.
Technical Details:
A Prometheus configuration file contains a scrape_configs list, and each scrape job describes one collection rule. Job-level fields define shared HTTP behavior, timing, and limits. Static target groups then list the addresses and labels that apply to those addresses. When a job has several groups, Prometheus treats each target as part of the same job while preserving the labels attached to its group.
Scrape timing has one strict relationship: a scrape timeout cannot exceed the scrape interval. A timeout longer than the interval would allow one scrape attempt to run past the next scheduled scrape. Prometheus also uses a duration syntax such as 15s, 1m, or 1m30s, so unit text matters as much as the number.
Rule Core:
| Config Part | Rule | Operational Meaning |
|---|---|---|
job_name |
Required, nonblank text. | Prometheus sets the default job label from this value. |
scheme |
http or https. |
The scheme is separate from the target address and can be overridden per target. |
metrics_path |
Must be a path beginning with /. |
Prometheus appends this path to each target's scheme and address. |
scrape_interval |
Positive Prometheus duration. | Controls how often Prometheus starts a scrape for the job. |
scrape_timeout |
Positive duration no greater than the interval. | Controls how long Prometheus waits before treating a scrape as failed. |
Static target labels can either describe a target or control how Prometheus scrapes it. Normal labels such as site, role, and env remain available for queries. Special labels such as __scheme__, __metrics_path__, __scrape_interval__, __scrape_timeout__, and __param_* influence the scrape before Prometheus stores the final series labels.
Transformation Core:
| Input Text | Generated Meaning | Review Check |
|---|---|---|
api01.example.internal:8443 |
Target address under targets. |
No protocol text or slash should appear in the target value. |
site=dc2 role=api |
Visible labels attached to the target group. | Label names must start with a letter or underscore and then use letters, numbers, or underscores. |
scheme=https |
__scheme__ scrape override. |
Use only when this target should differ from the job default. |
path=/actuator/prometheus |
__metrics_path__ scrape override. |
The path must begin with / and contain no spaces. |
timeout=5s |
__scrape_timeout__ scrape override. |
The value must be a valid Prometheus duration. |
param_module=http_2xx |
__param_module URL parameter override. |
Useful for exporter patterns that pass a module or probe value as a request parameter. |
Grouping does not change target behavior. Targets with identical label sets can share one static_configs entry, while targets with different labels or overrides need separate entries. Row-specific labels override common labels with the same name, which is helpful for a shared team or env value but easy to miss during review.
Validation Boundaries:
| Check | Boundary | Why It Matters |
|---|---|---|
| Target count | At least one valid target row is required. | A scrape job with no targets has no collection work. |
| Duplicate targets | Duplicates warn but do not block YAML generation. | Duplicates may be deliberate, but they often reveal a copy-paste mistake. |
| Honor labels | When enabled, scraped labels can win conflicts with labels attached by Prometheus. | This is important for federation and Pushgateway-style cases, but it can surprise normal scrape jobs. |
| Honor timestamps | Prometheus defaults to respecting timestamps exposed by targets. | Disabling timestamp honor can be useful only when target timestamps are unsafe for the workload. |
| Sample, target, and label limits | Zero omits the limit; positive values become job settings. | Limits protect Prometheus from runaway exporters but can also reject scrapes that exceed the configured cap. |
The generated YAML is best treated as a draft job entry. Validate the complete file with promtool check config, reload Prometheus only after the full file passes, and verify target health from Prometheus after the reload.
Limitations and Privacy Notes:
The generator prepares configuration text and review artifacts. It does not contact target endpoints, authenticate to exporters, test TLS settings, inspect exposed metrics, or reload a Prometheus server.
- Run final validation on the complete Prometheus file because surrounding config, rule files, and environment-specific paths can still matter.
- Treat copied or downloaded YAML, CSV, DOCX, and JSON as operational material when they contain internal hostnames, service names, team labels, or network paths.
- Check target health after deployment; a ready YAML draft cannot prove exporter reachability or scrape success.
Worked Examples:
A small node exporter job might use node01.example.internal:9100 site=dc1 role=node and node02.example.internal:9100 site=dc1 role=node with a 30s interval and 10s timeout. Scrape YAML should contain one grouped static config when grouping is enabled, and Target Ledger should show both targets in the same static group with two visible labels.
An application endpoint can keep the same job defaults while adding row-specific behavior: api01.example.internal:8443 site=dc2 role=api scheme=https path=/actuator/prometheus timeout=5s. Target Ledger should show visible labels for site and role, plus internal overrides for the HTTPS scheme, custom metrics path, and shorter timeout. Config Audit should still report the timeout as fitting inside the interval.
A failed draft that puts a protocol prefix before api01.example.internal:8443 role=api triggers Scrape config needs attention because the target includes protocol text. Move the protocol to Scheme or use scheme=https, then confirm that Scrape YAML contains the target as a host and optional port only.
FAQ:
Why does the target field reject protocol prefixes?
Prometheus static targets are host and optional port values. The scheme is a separate scrape setting, so use the Scheme field or a row override such as scheme=https.
Can one job mix different metrics paths?
Yes. Use the default Metrics path for most targets, then add path=/custom on rows that need a different path. Those rows appear with internal overrides in Target Ledger.
What does grouping identical label sets do?
Grouping combines targets that share the same labels into one static_configs entry. It shortens the YAML without changing the labels Prometheus applies to those targets.
Should honor_labels be enabled?
Leave it disabled for ordinary scrape jobs unless you intentionally want labels from the scraped metrics to win conflicts with labels attached by Prometheus. Federation and Pushgateway-style workflows are common reasons to consider it.
Does a ready result mean Prometheus will scrape successfully?
No. A ready result means the entered config draft passed local checks. Use promtool check config on the complete file, reload Prometheus, and then confirm target health inside Prometheus.
Glossary:
- Scrape job
- A Prometheus job entry that defines how a set of targets is scraped.
- Target
- A host and optional port that Prometheus contacts for metrics.
- Static config
- An explicit target group written directly into a Prometheus scrape configuration.
- Metrics path
- The HTTP path Prometheus requests from each target, commonly
/metrics. - Internal label
- A temporary Prometheus label that can control target scraping before final series labels are stored.
- Honor labels
- A scrape option that lets labels from scraped metrics win conflicts with labels attached by Prometheus.
- Sample limit
- A per-scrape cap on accepted samples after metric relabeling.
- Promtool
- The Prometheus command-line utility used to check configuration files and other Prometheus resources.
References:
- Configuration, Prometheus.
- Getting started, Prometheus.
- promtool, Prometheus.