-
Notifications
You must be signed in to change notification settings - Fork 464
Add total event, unencrypted message, and e2ee event counts to stats reporting (v2) #18371
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
Closed
MadLittleMods
wants to merge
9
commits into
develop
from
madlittlemods/export_total_message_count_v2
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7f044f9
Add total event, unencrypted message, and e2ee event counts to stats …
anoadragon453 eb89758
Update changelog PR number
MadLittleMods a0e94f7
Add `RETURNING` alternative for old versions of SQLite
MadLittleMods ddf77b5
Always clear the `event_stats` table when the background update starts
MadLittleMods 0b37f9f
Remove superfluous guest from `event_stats` tests
MadLittleMods 29c936f
WIP: Concurrent event insert test
MadLittleMods 3c873f9
Try sharded event_persisters
MadLittleMods 1cb9a0f
Make it more clear that it is a *threadless* thread pool
MadLittleMods d0e2a45
Try more things
MadLittleMods File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Add `total_event_count`, `total_message_count`, and `total_e2ee_event_count` fields to the homeserver usage statistics. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
Workaround
We already report
synapse_storage_events_persisted_eventsandsynapse_storage_events_persisted_events_sepmetrics which end up with a_totalsuffix when reported so you will seesynapse_storage_events_persisted_events_sep_totalfor example. Don't be confused by this_totalsuffix as it's just a Prometheus convention for counters and it tracks cumulative increments, not the absolute event count in SynapseWe additionally have a set of Prometheus rules to collect these metrics as
synapse_storage_events_persisted_by_event_typeWhich can be presented in Grafana,
Grafana panel JSON
{ "datasource": { "uid": "$datasource", "type": "prometheus" }, "fieldConfig": { "defaults": { "custom": { "lineWidth": 1, "fillOpacity": 80, "gradientMode": "none", "axisPlacement": "auto", "axisLabel": "", "axisColorMode": "text", "axisBorderShow": false, "scaleDistribution": { "type": "linear" }, "axisCenteredZero": false, "hideFrom": { "tooltip": false, "viz": false, "legend": false }, "thresholdsStyle": { "mode": "off" } }, "color": { "mode": "palette-classic" }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 80 } ] }, "min": 0, "unit": "none" }, "overrides": [ { "__systemRef": "hideSeriesFrom", "matcher": { "id": "byNames", "options": { "mode": "exclude", "names": [ "m.room.encrypted" ], "prefix": "All except:", "readOnly": true } }, "properties": [ { "id": "custom.hideFrom", "value": { "viz": true, "legend": false, "tooltip": false } } ] } ] }, "gridPos": { "h": 7, "w": 12, "x": 12, "y": 37 }, "id": 46, "options": { "orientation": "auto", "xTickLabelRotation": 0, "xTickLabelSpacing": 0, "showValue": "auto", "stacking": "normal", "groupWidth": 0.85, "barWidth": 0.97, "barRadius": 0, "fullHighlight": false, "tooltip": { "mode": "single", "sort": "none" }, "legend": { "showLegend": true, "displayMode": "list", "placement": "bottom", "calcs": [] } }, "pluginVersion": "10.4.1", "targets": [ { "datasource": { "uid": "$datasource" }, "editorMode": "code", "expr": "sum by (type) (increase(synapse_storage_events_persisted_by_event_type{job=~\"$job\",index=~\"$index\",instance=\"$instance\"}[1d]))", "format": "time_series", "instant": false, "intervalFactor": 1, "legendFormat": "__auto", "refId": "A", "step": 20, "interval": "1d" } ], "title": "Events per day by Type", "type": "barchart" }If you retain all of your Prometheus data forever, you can then go one step further and create absolute counts from this but it's usually common practice to only persist the last X months of metrics. To get absolute values, you will have to manually keep track and sum these daily counts.
Given that this PR would require further effort to figure out the concurrency problems or a refactor to a different solution, we're going to opt to close it in favor of this workaround. The people having to collate these reports, manually collect data anyway so we will just have them continue with the database queries or these metrics.
Overall, this kind of feature seems fine but turned out to be a lot more effort than originally planned and we don't want to continue if people can live without it for now.