-
Notifications
You must be signed in to change notification settings - Fork 43
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
Getting Counters into SD #144
Comments
@bill-within counter metrics are supported out of the box. Are you having any issues with that? The aggregator feature is only intended to reduce cardinality. |
@jkohen I am, when I define something as a counter, Prometheus will pick it up OK (adding _total and _created), but it's never visible in Stackdriver. Any Gauges I create come through just fine, however. |
& no errors/warnings in the prom or sidecar logs |
Can you share your Prometheus and sidecar configurations? It would be useful to see the Assigning to @bmoyles0117 after initial triage. |
You bet! Relevant config snippet:
Deployment args:
/metrics page snippet:
Metric created in app via:
Visible in Prometheus if I query 'time_service_calls_total':
|
Thanks for the configs, I'm going to start investigating now and will report back with what I find. |
Before I dig much deeper, I'm noticing an inconsistency between the metric names you're defining, and the ones you're searching for. Can you help me understand how from prometheus_client import start_http_server, Counter
import random
import time
BACKEND_CALLS = Counter('time_service_calls', 'Number of calls to the backend time service')
start_http_server(8080)
while True:
time.sleep(random.random())
BACKEND_CALLS.inc() When I curl the endpoint, I get the following, notice the metric names: $ curl -qs http://127.0.0.1:8080/metrics | grep time_service
# HELP time_service_calls Number of calls to the backend time service
# TYPE time_service_calls counter
time_service_calls 12.0
$ curl -qs http://127.0.0.1:8080/metrics | grep time_service
# HELP time_service_calls Number of calls to the backend time service
# TYPE time_service_calls counter
time_service_calls 17.0 |
I was surprised by that as well, however this is the first application I've instrumented with Prometheus and it happens for any Counter I create, so I figured that was normal. I'm using the standard python 3.7 from dockerhub (https://hub.docker.com/_/python) and the latest official python prometheus client off pypi (https://pypi.org/project/prometheus_client/). What does your environment look like? |
They look like they're coming from here: https://github.com/prometheus/client_python/blob/master/prometheus_client/metrics.py#L255 |
@bill-within thanks for the reference, it helped! Seems like with python 3.7, the prometheus libraries are using a new agreed, but undocumented standard for capturing counters with their original creation time. We're not handling this case in the prometheus sidecar, resulting in dropping these metrics. I'm working on a fix now, and will hopefully have it out by the end of the week. |
The patch has been merged into master, @StevenYCChou is the release shepherd for this week's release. I believe you should have an image that you can use by the end of the week. Once we confirm that you're receiving your counter metrics, we can close this issue. |
Excellent, thank you @bmoyles0117! |
Hi @bill-within , I have released a new version and please take a look: |
Looks perfect 👍 thank you @StevenYCChou! |
@bmoyles0117 I didn't feel like opening a ticket to ask this question was warranted, but please forgive me if this not the appropriate format for this question: is it possible to run this stackdriver-prometheus-sidecar outside of k8s? Or outside of docker entirely? I'm going to be scraping metrics from some mixed environments (GCE, EC2, bare metal) and I'd like to continue using the :9090/metrics -> prom -> SD pattern I've grown accustomed to, however these new prometheus instances won't be running in k8s. |
Hi,
Is it possible to get Counter-type metrics into SD, high-cardinality or not? I see the Cumulative aggregator, and I could manually create one for each of my individual counters, but that's not exactly ideal.
Prometheus has a Counter:
https://prometheus.io/docs/concepts/metric_types/
StackDriver has the same concept only they call it Cumulative:
https://cloud.google.com/monitoring/api/v3/metrics-details#metric-kinds
& I'd like to just map them 1-to-1 without having to update the stackdriver-prometheus-sidecar config every time I add a new one. I've been using Gauges for everything instead, but that feels a little dirty.
Thanks!
The text was updated successfully, but these errors were encountered: