-
Notifications
You must be signed in to change notification settings - Fork 73
Optionally export metrics for external monitoring #530
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
Open
isuldor
wants to merge
2
commits into
decred:master
Choose a base branch
from
isuldor:prometheus_instrumentation
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,44 @@ | ||
| ## Prometheus examples | ||
| A basic Prometheus setup is described in [prometheus-quickstart.md](prometheus-quickstart.md). This document provides examples for how a permanent Prometheus setup can be deployed. It is assumed you have some familiarity with Linux and Systemd. As these are all examples, they obviously need not be followed verbatim. Samples are provided as-is with minimum necessary descriptions. You should refer to [official documentation](https://prometheus.io/docs/prometheus/latest/configuration/configuration/) to fully understand them. Please find the following samples in the `docs/samples` directory: | ||
| - alerting.rules.yml | ||
| - alertmanager.service | ||
| - alertmanager.yml | ||
| - blackbox_exporter.service | ||
| - blackbox.yml | ||
| - prometheus.service | ||
| - prometheus.yml | ||
|
|
||
| ### Voting node health | ||
| The `alerting.rules.yml` example can proactively detect potentially transient failures: | ||
| - The node appears online, but `dcrd` has stalled (BlockHeightStalled) | ||
| - Block height is correct but `dcrwallet` doesn't agree with the other voting nodes about the state of the ticket pool (LiveTicketParity) | ||
|
|
||
| On my testnet vsp, which uses extremely cheap virtual servers, the first alert frequently catches problems early. The second scenario happens often, but resolves itself within a few minutes. So that alert is configured to wait for a much longer duration before firing. Definitely consider tuning how long an alert waits (eg. start with `for: 5m` and increase until false positives stop) before it fires. When the duration is tuned appropriately, these alerts can inform you of a problem before `dcrstakepool` itself collapses. At a minimum, when you find your `dcrstakepool` instance offline, you can pull up the Prometheus `/alerts` page and drill down to see which specific nodes aren't healthy. | ||
|
|
||
| ### Systemd service units | ||
| These [service units](https://www.freedesktop.org/wiki/Software/systemd/) assume you've set up Prometheus under various `/opt` subdirectories, with binaries stored in `/opt/bin`. They use an unprivileged user account to run the daemon. For your convenience, `ExecReload` has been configured so that you can reload configuration on the fly, e.g. `systemctl reload prometheus`. Assuming you went through the quickstart already, here is how you could set up the `prometheus` daemon : | ||
| ```bash | ||
| sudo mkdir -p /opt/bin | ||
| sudo mkdir -p /opt/prometheus/data | ||
| sudo cp -r prometheus-2.*.linux-amd64/{consoles,console_libraries,*.yml} /opt/prometheus/ | ||
| sudo cp prometheus-2.*.linux-amd64/{prometheus,promtool} /opt/bin/ | ||
| sudo useradd -Us /usr/bin/nologin -Md /opt/prometheus -c "Prometheus daemon" prometheus | ||
| sudo chown prometheus:prometheus /opt/prometheus/data | ||
| sudo cp prometheus.service /etc/systemd/system | ||
| sudo systemctl daemon-reload | ||
| sudo systemctl enable prometheus | ||
| sudo systemctl start prometheus | ||
| ``` | ||
|
|
||
| ### Mobile push notifications | ||
| The provided `alertmanager.yml` example sends alerts to the api of a service called [pushover.net](https://pushover.net/). For one time fee, you can use their api to send push notifications directly to your Android or iOS mobile device. Alertmanager supports numerous notification methods, including a generic webhook api, PagerDuty (a significantly more expensive service), OpsGenie (free for up to 5 users), and more. | ||
|
|
||
| ### Blackbox Exporter | ||
| [Blackbox exporter](https://github.com/prometheus/blackbox_exporter/) is a Prometheus daemon you can deploy to monitor http endpoints like `dcrstakepool` itself. See the relevant job named "health-checks" in `prometheus.yml`. The service unit assumes configuration is in a directory `/opt/prometheus` owned by the `prometheus` user like in the example above. | ||
|
|
||
| ### Observability with Grafana | ||
| Once you've set up alerts, you might find it valuable to visualize your metrics. [Grafana](https://grafana.com/docs/) supports Prometheus as a datasource out of the box, and can be set up by simply adding a third party repository. | ||
|
|
||
| ### Node Exporter | ||
| To monitor basic system statistics like CPU usage, RAM, disk IO, etc, there is [Node Exporter](https://github.com/prometheus/node_exporter). It's another daemon you can run on your nodes to export system-level metrics. There's an [example dashboard](https://grafana.com/grafana/dashboards/1860) that visualizes all of the numerous collected metrics. | ||
|
|
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.