question
stringlengths
11
28.2k
answer
stringlengths
26
27.7k
tag
stringclasses
130 values
question_id
int64
935
78.4M
score
int64
10
5.49k
I'm trying to figure out how to add a label to a prometheus collector. Any ideas what I'm missing here? I have two files: main.go and collector.go I used the following link as a guide. https://rsmitty.github.io/Prometheus-Exporters/ I mocked up this example, so I could post it here. I'm ultimately not going to pull "da...
I figured it out. I had to declare the label where I was calling the NewDesc method and then pass the value within the MustNewConstMetric method Here is my new "newCollector" with the "hostname" label. func newCollector() *cmdCollector { return &cmdCollector{ cmdMetric: prometheus.NewDesc("cmd_result", ...
Prometheus
53,017,421
10
In Grafana I have a drop down for variable $topic with values "topic_A" "topic_B" "topic_A" is selected so $topic = "topic_A" I want to query prometheus using function{topic=$topic} and that works fine. How would I implement function{topic="$topic" + "_ERROR"} (this fails) where what I want to query would be "topic_...
UPDATE 2020-08-17: There is a new syntax for Grafana variables, new format is to use curly braces after dollar sign: function{topic=~"${topic}_ERROR"} Double brackets syntax is deprecated and will be deleted soon. Also now you can define the format of the variable, which may help to solve some spacial characters issue...
Prometheus
59,792,809
10
Prometheus allows me to dynamically load targets with file_sd_config from a .json file like this #prometheus.yaml - job_name: 'kube-metrics' file_sd_configs: - files: - 'targets.json' [ { "labels": { "job": "kube-metrics" }, "targets": [ "http://node1:8080", "http://node2:8080" ...
You can use relabel_config in Prometheus config to change __metrics_path__ label config. The principe is to provide the metrics path in your targets under the form host:port/path/of/metrics (note: drop the http://, it is in scheme parameter of scrape_config) [ { "targets": [ "node1:8080/first-metrics", ...
Prometheus
59,866,342
10
I am trying to create a table/chart in Grafana showing the total number of unique users who have logged in to a given application over a given time range (e.g. last 24 hours). I have a metric, app_request_path which records the number of requests hitting a specific path per minute: app_request_count{app="my-app", path=...
count without (username)(app_request_count) count_values is for metric values, count is for time series. It's also not advised to have something like usernames as label values as they tend to be high cardinality. They may also be PII, which could have legal implications.
Prometheus
59,935,902
10
I use MicroMeter gauges in a Spring Boot 2 application to track statuses of objects. On status change, the statusArrived() method is called. This function should update the gauge related to that object. Here is my current implementation: public class PrometheusStatusLogger { private int currentStatus; public...
Since all your gauges are referencing the same currentStatus, when the new value comes in, all the gauge's source is changed. Instead use a map to track all the current status by id: public class PrometheusStatusLogger { private Map<String, Integer> currentStatuses = new HashMap<>(); public void statusArrive...
Prometheus
60,171,522
10
I would like a Grafana variable that contains all the Prometheus metric names with a given prefix. I would like to do this so I can control what graphs are displayed with a drop down menu. I'd like to be able to display all the metrics matching the prefix without having to create a query for each one. In the Grafana do...
In promql, you can select metrics by name by using the internal __name__ label: {__name__=~"mysql_.*"} And then, you can reuse it to extract the metrics name using query label_values(): label_values({__name__=~"mysql_.*"},__name__) This will populate your variable with metrics name starting with mysql_. You can get t...
Prometheus
60,874,653
10
Let's take this processor as an example: a CPU with 2 cores and 4 threads (2 threads per core). From what I've read, such a CPU has 2 physical cores but can process 4 threads simultaneously through hyper threading. But, in reality, one physical core can only truly run one thread at a time, but using hyper threading, th...
This gets very complicated. So k8s doesn't actually manage this it just provides a layer on top of the underlying container runtime (docker, containerd etc). When you configure a container to use 100 millicore k8's hands that down to the underlying container runtime and the runtime deals with it. Now once you start goi...
Prometheus
71,944,390
10