-
Notifications
You must be signed in to change notification settings - Fork 4.1k
metric: add /metrics endpoint with static labels #143536
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
Conversation
a895084 to
cc9d0a8
Compare
pkg/server/status/recorder.go
Outdated
| metric.WithIncludeAggregateMetrics(includeAggregateMetrics), | ||
| metric.WithUseStaticLabels(useStaticLabels), | ||
| } | ||
| mr.mu.RLock() |
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'm not sure if this makes any difference, but I like when objects are locked as the first stage of a function, even if the critical section is further along. It's almost as if it's part of the function signature which I find useful.
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.
Done.
cc9d0a8 to
44da15e
Compare
A new metrics endpoint that's Prometheus-compatible, is now available
at `/metrics` similarly to `/_status/vars`. This endpoint will emit
statically labeled metrics if the metric metadata defines static
labels and a labeled name.
Here's an example of what this looks like on a demo cluster with
multitenancy using the few metrics that have been migrated in this PR
from SQL:
```
http GET http://localhost:8080/_status/vars cluster==system | grep sql_insert_count
# HELP sql_insert_count_internal Number of SQL INSERT statements successfully executed (internal queries)
# TYPE sql_insert_count_internal counter
sql_insert_count_internal{node_id="1",tenant="system"} 138
sql_insert_count_internal{node_id="1",tenant="demoapp"} 152
# HELP sql_insert_count Number of SQL INSERT statements successfully executed
# TYPE sql_insert_count counter
sql_insert_count{node_id="1",tenant="system"} 2
sql_insert_count{node_id="1",tenant="demoapp"} 73
~/go/src/github.com/cockroachdb/cockroach remotes/dhartunian/davidh/push-orrrntktwptm* ≡
❯
http GET http://localhost:8080/metrics cluster==system | grep sql_insert_count
~/go/src/github.com/cockroachdb/cockroach remotes/dhartunian/davidh/push-orrrntktwptm* ≡
❯
http GET http://localhost:8080/metrics cluster==system | grep sql_count
# HELP sql_count Number of SQL UPDATE statements successfully executed (internal queries)
# TYPE sql_count counter
sql_count{node_id="1",tenant="system",query_type="select",query_internal="true"} 172
sql_count{node_id="1",tenant="system",query_type="update"} 0
sql_count{node_id="1",tenant="system",query_type="update",query_internal="true"} 67
sql_count{node_id="1",tenant="system",query_type="select"} 0
sql_count{node_id="1",tenant="system",query_type="delete",query_internal="true"} 29
sql_count{node_id="1",tenant="system",query_type="insert",query_internal="true"} 138
sql_count{node_id="1",tenant="system",query_type="delete"} 0
sql_count{node_id="1",tenant="system",query_type="insert"} 2
sql_count{node_id="1",tenant="demoapp",query_type="update",query_internal="true"} 124
sql_count{node_id="1",tenant="demoapp",query_type="update"} 0
sql_count{node_id="1",tenant="demoapp",query_type="insert"} 269
sql_count{node_id="1",tenant="demoapp",query_type="insert",query_internal="true"} 152
sql_count{node_id="1",tenant="demoapp",query_type="select",query_internal="true"} 243
sql_count{node_id="1",tenant="demoapp",query_type="delete",query_internal="true"} 57
sql_count{node_id="1",tenant="demoapp",query_type="select"} 593
sql_count{node_id="1",tenant="demoapp",query_type="delete"} 0
```
Resolves: cockroachdb#142570
Release note (ops change): Prometheus metrics are now also available
at the `/metrics` endpoint in addition to `/_status/vars`. This new
endpoint will evolve more rapidly as we migrate metrics to use labels
where previously different metric names were defined. Customers can
continue to use `/_status/vars` where the names will not change.
44da15e to
b87e008
Compare
|
TFTR! bors r=angles-n-daemons |
|
Build failed (retrying...): |
Previously, only metrics for *executed* `SELECT|UPDATE|DELETE|INSERT` statements are labeled, while their *started* equivalent are not labeled. This commit is to label these metrics. Ref cockroachdb#143536 Release note (ops change): TBD <what was there before: Previously, ...> <why it needed to change: This was inadequate because ...> <what you did about it: To address this, this patch ...>
Previously, only metrics for *executed* `SELECT|UPDATE|DELETE|INSERT` statements are labeled, while their *started* equivalent are not labeled. This commit is to label these metrics. Ref cockroachdb#143536 Release note (ops change): TBD <what was there before: Previously, ...> <why it needed to change: This was inadequate because ...> <what you did about it: To address this, this patch ...>
Previously, only metrics for *executed* `SELECT|UPDATE|DELETE|INSERT` statements are labeled, while their *started* equivalent are not labeled. This commit is to label these metrics. Ref cockroachdb#143536 Release note (ops change): TBD <what was there before: Previously, ...> <why it needed to change: This was inadequate because ...> <what you did about it: To address this, this patch ...>
Previously, only metrics for *executed* `SELECT|UPDATE|DELETE|INSERT` statements are labeled, while their *started* equivalent are not labeled. This commit is to label these metrics. Ref cockroachdb#143536 Release note (ops change): TBD <what was there before: Previously, ...> <why it needed to change: This was inadequate because ...> <what you did about it: To address this, this patch ...>
Previously, only metrics for *executed* `SELECT|UPDATE|DELETE|INSERT` statements are labeled, while their *started* equivalent are not labeled. This commit is to label these metrics. Ref cockroachdb#143536 Release note (ops change): sql.select.started.count, sql.insert.started.count, sql.update.started.count, sql.delete.started.count are now labeled with sql.started.count. <what was there before: Previously, ...> <why it needed to change: This was inadequate because ...> <what you did about it: To address this, this patch ...>
Previously, only metrics for *executed* `SELECT|UPDATE|DELETE|INSERT` statements are labeled, while their *started* equivalent are not labeled. This commit is to label these metrics. Ref cockroachdb#143536 Release note (ops change): sql.select.started.count, sql.insert.started.count, sql.update.started.count, sql.delete.started.count are now labeled with sql.started.count. <what was there before: Previously, ...> <why it needed to change: This was inadequate because ...> <what you did about it: To address this, this patch ...>
Previously, only metrics for *executed* `SELECT|UPDATE|DELETE|INSERT` statements are labeled, while their *started* equivalent are not labeled. This commit is to label these metrics. Ref #143536 Release note (ops change): sql.select.started.count, sql.insert.started.count, sql.update.started.count, sql.delete.started.count are now labeled with sql.started.count. <what was there before: Previously, ...> <why it needed to change: This was inadequate because ...> <what you did about it: To address this, this patch ...>
Previously, only metrics for *executed* `SELECT|UPDATE|DELETE|INSERT` statements are labeled, while their *started* equivalent are not labeled. This commit is to label these metrics. Ref cockroachdb#143536 Release note (ops change): sql.select.started.count, sql.insert.started.count, sql.update.started.count, sql.delete.started.count are now labeled with sql.started.count.
A new metrics endpoint that's Prometheus-compatible, is now available
at
/metricssimilarly to/_status/vars. This endpoint will emitstatically labeled metrics if the metric metadata defines static
labels and a labeled name.
Here's an example of what this looks like on a demo cluster with
multitenancy using the few metrics that have been migrated in this PR
from SQL:
Resolves: #142570
Release note (ops change): Prometheus metrics are now also available
at the
/metricsendpoint in addition to/_status/vars. This newendpoint will evolve more rapidly as we migrate metrics to use labels
where previously different metric names were defined. Customers can
continue to use
/_status/varswhere the names will not change.First commit can be reviewed here: #143511