Which of the following metrics is unsuitable for a Prometheus setup?
Answer(s): D
The metric user_last_login_timestamp_seconds{email="john.doe@example.com"} is unsuitable for Prometheus because it includes a high-cardinality label (email). Each unique email address would generate a separate time series, potentially numbering in the millions, which severely impactsPrometheus performance and memory usage.Prometheus is optimized for low- to medium-cardinality metrics that represent system-wide behavior rather than per-user data. High-cardinality metrics cause data explosion, complicating queries and overwhelming the storage engine.By contrast, the other metrics--prometheus_engine_query_log_enabled, promhttp_metric_handler_requests_total{code="500"}, and http_response_total{handler="static/*filepath"}--adhere to Prometheus best practices. They represent operational or service-level metrics with limited, manageable label value sets.
Extracted and verified from Prometheus documentation Metric and Label Naming Best Practices, Cardinality Management, and Anti-Patterns for Metric Design sections.
What Prometheus component would you use if targets are running behind a Firewall/NAT?
When Prometheus targets are behind firewalls or NAT and cannot be reached directly by the Prometheus server's pull mechanism, the recommended component to use is PushProx.PushProx works by reversing the usual pull model. It consists of a PushProx Proxy (accessible by Prometheus) and PushProx Clients (running alongside the targets). The clients establish outbound connections to the proxy, which allows Prometheus to "pull" metrics indirectly. This approach bypasses network restrictions without compromising the Prometheus data model.Unlike the Pushgateway (which is used for short-lived batch jobs, not network-isolated targets), PushProx maintains the Prometheus "pull" semantics while accommodating environments where direct scraping is impossible.
Verified from Prometheus documentation and official PushProx design notes Monitoring Behind NAT/Firewall, PushProx Overview, and Architecture and Usage Scenarios sections.
You'd like to monitor a short-lived batch job. What Prometheus component would you use?
Answer(s): B
Prometheus normally operates on a pull-based model, where it scrapes metrics from long-running targets. However, short-lived batch jobs (such as cron jobs or data processing tasks) often finish before Prometheus can scrape them. To handle this scenario, Prometheus provides the Pushgateway component.The Pushgateway allows ephemeral jobs to push their metrics to an intermediary gateway. Prometheus then scrapes these metrics from the Pushgateway like any other target. This ensures short-lived jobs have their metrics preserved even after completion.The Pushgateway should not be used for continuously running applications because it breaks Prometheus's usual target lifecycle semantics. Instead, it is intended solely for transient job metrics, like backups or CI/CD tasks.
Verified from Prometheus documentation Pushing Metrics The Pushgateway and Use Cases for Short-Lived Jobs sections.
How do you calculate the average request duration during the last 5 minutes from a histogram or summary called http_request_duration_seconds?
Answer(s): A
In Prometheus, histograms and summaries expose metrics with _sum and _count suffixes to represent total accumulated values and sample counts, respectively. To compute the average request duration over a given time window (for example, 5 minutes), you divide the rate of increase of _sum by the rate of increase of _count:\text{Average duration} =\frac{\text{rate(http_request_duration_seconds_sum[5m])}}{\text{rate(http_request_duration_seco nds_count[5m])}}Here,http_request_duration_seconds_sum represents the total accumulated request time, and http_request_duration_seconds_count represents the number of requests observed.By dividing these rates, you obtain the average request duration per request over the specified time range.
Extracted and verified from Prometheus documentation Querying Histograms and Summaries, PromQL Rate Function, and Metric Naming Conventions sections.
If the vector selector foo[5m] contains 1 1 NaN, what would max_over_time(foo[5m]) return?
In PromQL, range vector functions like max_over_time() compute an aggregate value (in this case,the maximum) over all samples within a specified time range. The function ignores NaN (Not-a- Number) values when computing the result.Given the range vector foo[5m] containing samples [1, 1, NaN], the maximum value among the valid numeric samples is 1. Therefore, max_over_time(foo[5m]) returns 1.Prometheus functions handle missing or invalid data points gracefully--ignoring NaN ensures stable calculations even when intermittent collection issues or resets occur. The function only errors if the selector is syntactically invalid or if no numeric samples exist at all.
Verified from Prometheus documentation PromQL Range Vector Functions, Aggregation Over Time Functions, and Handling NaN Values in PromQL sections.
Post your Comments and Discuss Linux Foundation PCA exam prep with other Community members:
Our website is free, but we have to fight against AI bots and content theft. We're sorry for the inconvenience caused by these security measures. You can access the rest of the PCA content, but please register or login to continue.