How to find monitoring

This guide documents how to find monitoring within Sourcegraph’s source code. Sourcegraph employees should also refer to the handbook’s monitoring section for Sourcegraph-specific documentation. The developing observability page contains relevant documentation as well.

Alerts

Alerts are defined in the monitoring/definitions package—for example, querying for definitions of Warning or Critical will surface all Sourcegraph alerts.

Metrics

You can use Sourcegraph itself to search for metrics definitions—for example, by querying for usages of prometheus.HistogramOpts.

Sometimes the metrics are hard to find because their name declarations are not literal strings, but are concatenated in code from variables. In these cases you can try a specialized tool called promgrep to find them.

go get github.com/sourcegraph/promgrep
# in the root `sourcegraph/sourcegraph` source directory
promgrep <some_partial_metric_name> # no arguments lists all declared metrics