PCA Metric Collection & Data Modeling 1 — Questions and Answers
Question 1: What is the main purpose of metrics in Prometheus?
- To store logs
- To provide quantitative data on system performance (Correct answer)
- To store alerts
- To monitor configurations
Correct answer: To provide quantitative data on system performance
Metrics in Prometheus are numerical measurements collected over time, representing the state and behavior of a system or application. Their main purpose is to quantify various aspects of performance, such as CPU usage, memory consumption, request rates, and error counts. This quantitative data is essential for understanding system health, identifying trends, and enabling effective monitoring, alerting, and troubleshooting.
Question 2: How does Prometheus collect metrics?
- By pulling data from APIs
- By scraping endpoints over HTTP (Correct answer)
- By pushing data to servers
- By importing CSV files
Correct answer: By scraping endpoints over HTTP
Prometheus primarily uses a pull model to collect metrics. It is configured to periodically scrape (fetch) metrics from instrumented applications or services by making HTTP requests to specific `/metrics` endpoints. This method allows Prometheus to actively collect data from targets rather than waiting for data to be pushed to it, ensuring consistent and controlled data acquisition.
Question 3: What is a metric in Prometheus?
- A data point at a single time
- A series of time-stamped data points representing a metric (Correct answer)
- A collection of logs
- A configuration setting
Correct answer: A series of time-stamped data points representing a metric
In Prometheus, a metric is not just a single data point but a collection of time-stamped values that track a specific measurement over time. Each data point in this series consists of a numerical value and the exact time it was recorded. This time-series nature is fundamental to how Prometheus stores and queries monitoring data, allowing for historical analysis, trend identification, and powerful aggregations.
Question 4: What is the purpose of labels in Prometheus metrics?
- To classify metrics into categories
- To provide additional context for metrics (Correct answer)
- To store timestamps
- To track changes over time
Correct answer: To provide additional context for metrics
Labels are key-value pairs that add dimensions to a metric, such as instance, job or status code. They give each series context and let you filter and aggregate across those dimensions.
Question 5: What is the use of a metric’s timestamp?
- To track performance changes over time (Correct answer)
- To set alert thresholds
- To classify metric types
- To label metrics
Correct answer: To track performance changes over time
Every sample is stored with a timestamp, which orders values in time. This lets Prometheus show how a metric changes, calculate rates and trends, and align series in queries.
Question 6: What are histograms used for in Prometheus?
- To track events
- To monitor distribution of values like durations (Correct answer)
- To store time-series data
- To track errors
Correct answer: To monitor distribution of values like durations
A histogram samples observations into configurable buckets, such as request durations. This lets you see the distribution of values and estimate quantiles with histogram_quantile() at query time.
Question 7: What is a counter in Prometheus?
- A metric that counts events over time (Correct answer)
- A metric that tracks values over time
- A metric that decreases over time
- A gauge of memory usage
Correct answer: A metric that counts events over time
A counter is a cumulative metric that only increases, or resets to zero on restart. It counts events such as requests or errors, and you usually query it with rate() or increase().
Question 8: How are Prometheus metrics structured?
- As time-stamped data points with names and labels (Correct answer)
- As logs and alerts
- As database records
- As simple data points without time
Correct answer: As time-stamped data points with names and labels
Each Prometheus time series is identified by a metric name and a set of labels. It holds a sequence of timestamped float values.
Question 9: What is the role of the Prometheus Pushgateway?
- To store metrics
- To allow short-lived jobs to push metrics (Correct answer)
- To store logs
- To query data
Correct answer: To allow short-lived jobs to push metrics
The Pushgateway lets short-lived batch jobs push their metrics to it before they exit. Prometheus then scrapes the Pushgateway like any other target, so the metrics are not lost.