Repository navigation
Feat/metrics - #1022
Merged
Merged
Feat/metrics#1022
Conversation
…re, Celery signals and search-event logs
…) and measure them
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
⛔ Files ignored due to path filters: 1
📒 Files selected for processing: 72
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add Prometheus metrics for usage and service health
Cantus Ultimus had no observability: no metrics, no Django logging, and a Google Analytics snippet that has collected nothing since 2023. This PR adds a low-cardinality set of Prometheus metrics. They are scraped by the cluster's existing kube-prometheus-stack, for production only. Alerts and Grafana dashboards will follow in a separate PR built on these series.
What it measures
Usage
Service health
Collection state (inventory, computed when Prometheus scrapes)
cantus_build_infowith the git SHAInfrastructure
rabbitmq_prometheusplugin, including per-queue depth and consumerssolr-exportersidecar, which ships in the Solr imageSearch text is never a metric label. Instead, each search writes one JSON line to stdout with the field, the normalized term, the number of hits and the client type. It contains no IP address, user agent or user.
How it works
cantus-appcantus-celerycantus-metrics-exportermetrics-exporterDeployment runningmanage.py serve_metrics; queries Postgres and Solr, caches the result for 60scantus-rabbitmqcantus-solrsolr-exportersidecarPROMETHEUS_MULTIPROC_DIRis exported only by the launcher scripts (django-config.sh, the newcelery-worker.sh). Sokubectl exec … manage.pyand the Celery liveness probe don't write files into the shared directory.manuscript_idis used only for public manuscripts; anything else becomesother.clientis one ofbrowser/bot/api/probe.routeis the URL pattern's name.release: kube-prom-stackand match production labels only. Staging shares the namespace and is deliberately not scraped.Fixes included
timeoutto http.client on Python 2, so on Python 3 a hung Solr could block a gunicorn worker until the 600s request timeout. The newhelpers/solr_client.make_solr()sets the timeout on the underlying connection and is now used everywhere. Defaults:SOLR_TIMEOUT10s for requests,SOLR_INDEX_TIMEOUT120s for indexing.wait_until_solr_ready.execs fromdjango-config.sh. It runs as PID 1 and receives SIGTERM directly, so shutdown is graceful.Deploying
The manifests are applied by hand after this PR has been merged and deployed. The new celery command,
/code/celery-worker.sh, doesn't exist in older images. Full steps are ink8s/MIGRATION.md→ Monitoring.solr/statefulset.yamlrestarts Solr; reopening the core takes about 100s.metrics-exporterand thesolr-exportersidecar only once they exist, so the first deploy after merge won't fail.Testing
runtests.py cantusdata.test.core: 194 tests pass, 31 of them new intest/core/metrics/.kill -9on a worker, its counters are kept and the exit is counted.task_receivedin the main process and the task execution in the pool child, served from the main process.serve_metricscollects with no errors, and the second scrape is served from the cache.kubectl apply --dry-run=server.Summary by CodeRabbit
New Features
Documentation