Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Counter not start from zero #1853

Closed
chocopowwwa opened this Issue Jul 28, 2016 · 7 comments

Comments

Projects
None yet
2 participants
@chocopowwwa
Copy link

chocopowwwa commented Jul 28, 2016

What did you do?
Tailing Nginx log and parse and publish it using Mtail (mine quiet similar like https://github.com/ipfs/infrastructure/blob/master/mtail/progs/nginx.mtail), the probem is that when the mtail starts it publish metrics like this

TYPE http_requests_total counter

TYPE http_request_duration_milliseconds_sum counter

TYPE http_response_size_bytes_sum counter

and after i make several http requests ( for example 15 http requests ), mtail will read the logs and publish metrics like

TYPE http_requests_total counter

http_requests_total{airlines="ZumaAir", code="404",method="get",vhost="localhost",prog="nginxlog.mtail",instance="funbox"} 15

TYPE http_request_duration_milliseconds_sum counter

TYPE http_response_size_bytes_sum counter

but prometheus will assume that the counters starts from 15 not 0
MY Query:
irate(http_requests_total{job="apache2",airlines=~"$airlines",code!="500"}[$interval])
NB: $airlines is ZumaAir
total cnt

as you see on the image, becausei didn't introduce the metrics first to prometheus and set its initial value ( like for example 0 ) the total values of the query it will be less than the actual sum of the metrics

What did you expect to see?
i expect the total of the query is the same as the total of the vents, is the any possible to assume that if the metrics hasn't introduced to promethus it will assume that the metrics starts from zero?

What did you see instead? Under which circumstances?
the total of the query isn't the same as the total of the metrics
also it makes no change the the graph

Environment

  • System information:
    Linux 4.4.12-boot2docker x86_64
  • Prometheus version:
    1.0.1
  • Alertmanager version:
  • Prometheus configuration file:
    • job_name: "apache2"
      scrape_interval: 5s
      static_configs:
      • targets: ["192.168.50.4:3903"]
  • Alertmanager configuration file:
  • Logs:
@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Jul 28, 2016

There's not much we can do here, irate only looks at two samples at a time. Without a sample to go before the 15 value, we don't have anything to compare it to.

If we did what you suggested it'd be far worse, as every network blip would lead to a massive spurious spike in your graphs.

@chocopowwwa

This comment has been minimized.

Copy link
Author

chocopowwwa commented Jul 28, 2016

hmm sorry ask this because i really confuse,
then how do i suppose to show request per second/minute foreach http code from nginx log? i tried to use increase but the numbers doesnt make sense to me the only make sense is irate

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Jul 28, 2016

You appear to be doing this correctly, this is what this sort of query produces on a sparse metric where you don't know the label values in advance.

If you can pre-populate the metric with 0 for all potential timeseries you would get better results, but I'm guessing that's not possible here. See https://prometheus.io/docs/practices/instrumentation/#avoid-missing-metrics

@chocopowwwa

This comment has been minimized.

Copy link
Author

chocopowwwa commented Jul 28, 2016

Oh now i got it, thanks
any plan for the future for this ( like adding special prefix to the metrics name maybe? )

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Jul 28, 2016

There's #1673 discussing this, but I don't see any way to make this workable in a sane way.

There's other features in future that may let you implement such a thing yourself.

@chocopowwwa

This comment has been minimized.

Copy link
Author

chocopowwwa commented Jul 28, 2016

thank you 😃

@lock

This comment has been minimized.

Copy link

lock bot commented Mar 24, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 24, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.