-
-
Notifications
You must be signed in to change notification settings - Fork 218
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
monitoring functional #26876
monitoring functional #26876
Conversation
Co-Authored-By: Daniel Miller <[email protected]>
This change means we don't have to instantiate a new class when applying the tags which simplifies the class structure a lot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this code structure and the resulting API very much.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the functional interface, thanks.
|
||
|
||
def prometheus_metrics(request): | ||
"""Exports /metrics as a Django view. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this view used for? Should it be protected by an admin-only decorator? I'm assuming this is not the only interface for viewing prometheus metrics... seems like it would be bad if metrics became unavailable if this django view became inaccessible for whatever reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because Prometheus is primarily a pull based system the metrics need to be exposed as a view. There are a few options for this:
- As a Django view
- this can either be protected by a shared secret / basic auth or, since it will be behind nginx in production we can deny access to it via the proxy.
- A separate HTTP server run on Django startup
prometheus_client.start_http_server(port, addr=addr)
- A completely separate HTTP server
I'm leaning towards 3: f1874e4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that makes sense.
- As a Django view ... since it will be behind nginx in production we can deny access to it via the proxy
I'm -1 on this option if it's not authenticated in some way. It sounds like it may increase the complexity of proxy configuration, and someone who is setting up their own instance of HQ but doesn't know that it should be hidden may inadvertently advertise their metrics to the world.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we went that route I would update commcare-cloud to have the correct configuration by default. But I think for now I'll remove this view or restrict it's access.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm done with this PR for now and will do further work in a new branch. |
=========== | ||
|
||
* All metrics must use the prefix 'commcare.' | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, thanks for adding!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to echo the feedback on the great interface. I really like the approach you've taken here.
And great docs. In fact, it was the reference to the Datadog tagging docs that made me think that split(':')
might need to be a split(':', 1)
.
Co-Authored-By: Norman Hooper <[email protected]>
DD metrics changes:
|
def _histogram(self, name: str, value: float, bucket_tag: str, buckets: List[int], bucket_unit: str = '', | ||
tags: dict = None, documentation: str = ''): | ||
""" | ||
A cumulative histogram with a base metric name of <basename> exposes multiple time series |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You missed the one on this line
A cumulative histogram with a base metric name of <basename> exposes multiple time series | |
A cumulative histogram with a base metric name of <name> exposes multiple time series |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks: #26916
Re-take of #26837 that takes a simplified approach.
The class based implementation was much more complex and since most of the calls are single use this approach seemed cleaner.
SUMMARY
Initial implementation of #26816
Initial code structure and classes to allow supporting multiple monitoring backends. Current support for Datadog and Prometheus.
Outstanding work (not for this PR):
Corresponding commcare-cloud change: dimagi/commcare-cloud#3721