I have the below configuration. I would like to scrape the cpu metric every second and then I have Grafana set up to auto refresh every 5s. The problem is that there seems to be a lag between when I set the CPU to a value (i.e. 100%) and when the metrics show up in Prometheus. The lag is about 30 seconds. Once the metrics DO show up in Prometheus, Grafana will update previous values displayed int he graph to the correct values (so basically 30 seconds after the time period in the graph the data is correct but before that it’s showing lagged data). How Can I update grafana agent to send the metric faster?
prometheus.exporter.windows "immediate" {
enabled_collectors = ["cpu"]
}
prometheus.scrape "windows_immediate_scraper" {
scrape_interval = "1s"
scrape_timeout = "1s"
targets = prometheus.exporter.windows.immediate.targets
forward_to = [prometheus.relabel.set_instance_to_hostname.receiver]
}
////////////// RELABELER (to set "Instance" to machine name) //////////////////////
prometheus.relabel "set_instance_to_hostname" {
forward_to = [prometheus.remote_write.default.receiver]
rule {
action = "replace"
source_labels = ["instance"]
replacement = constants.hostname
target_label = "instance"
}
}
////////////////////////////// Prometheus writer /////////////////////////////////////////
prometheus.remote_write "default" {
endpoint {
url = "http://localhost:9090/api/v1/write" //Prometheus
}
}
and then I am executing the promql query:
100 - (avg by (instance) (irate(windows_cpu_time_total{instance="MSSQL-MGMT",mode="idle"}[1s])) * 100)