Skip to content

Commit

Permalink
make longterm monitoring deployable on a different server
Browse files Browse the repository at this point in the history
  • Loading branch information
mishaschwartz committed Jun 25, 2024
1 parent 0307996 commit 2eab8b7
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 23 deletions.
18 changes: 13 additions & 5 deletions birdhouse/optional-components/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -451,19 +451,27 @@ This is a second prometheus instance that collects longterm monitoring metrics f
(the one created by the ``components/monitoring`` component).

Longterm metrics are any prometheus rule that have the label ``group: longterm-metrics`` or in other words are
selectable using prometheus' ``'{group="longterm-metrics"}'`` query filter. To see which longterm metric rules are
added by default see the ``optional-components/prometheus-longterm-metrics/config/monitoring/prometheus.rules.template``.
selectable using prometheus' ``'{group="longterm-metrics"}'`` query filter. To add some default longterm metrics rules
also enable the ``prometheus-longterm-rules`` component.

If you do not want the default longterm-metric rules included, set the ``PROMETHEUS_LONGTERM_RULES_FILE`` to anything
other than ``True`` in your ``env.local`` file. You may want to do this if you've created your own set of rules in
another component that you would like to use instead of the default ones.
You may also choose to create your own set of rules in another component that you would like to use instead of the
default ones.

To configure this component:

* update the ``PROMETHEUS_LONGTERM_RETENTION_TIME`` variable to set how long the data will be kept by prometheus

Enabling this component creates the additional endpoint ``/prometheus-longterm-metrics``.

Prometheus Long-term Rules
--------------------------

This adds some default longterm metrics rules to the `prometheus` component for use by the `prometheus-longterm-metrics`
component. These rules all have the label ``group: longterm-metrics``.

To see which rules are added, check out the
`optional-components/prometheus-longterm-rules/config/monitoring/prometheus.rules` file.

Thanos
------

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
export PROMETHEUS_LONGTERM_VERSION='${PROMETHEUS_VERSION:-"v2.52.0"}'
export PROMETHEUS_LONGTERM_DOCKER='${PROMETHEUS_DOCKER:-prom/prometheus}'
export PROMETHEUS_LONGTERM_IMAGE='${PROMETHEUS_LONGTERM_DOCKER}:${PROMETHEUS_LONGTERM_VERSION}'

export PROMETHEUS_LONGTERM_RETENTION_TIME=1y
export PROMETHEUS_LONGTERM_ENABLE_DEFAULT_RULES=True
export PROMETHEUS_LONGTERM_SCRAPE_INTERVAL=1h

# These are the prometheus defaults
export PROMETHEUS_LONGTERM_TSDB_MIN_BLOCK_DURATION=2h
export PROMETHEUS_LONGTERM_TSDB_MAX_BLOCK_DURATION=1d12h

export PROMETHEUS_LONGTERM_RULES_FILE='$([ "${PROMETHEUS_LONGTERM_ENABLE_DEFAULT_RULES}" = "True" ] && echo prometheus.rules || echo prometheus.null.rules)'
# These are the targets that
export PROMETHEUS_LONGTERM_TARGETS='["prometheus:9090"]' # yaml list syntax

OPTIONAL_VARS="
$OPTIONAL_VARS
\$PROMETHEUS_LONGTERM_SCRAPE_INTERVAL
\$PROMETHEUS_LONGTERM_TARGETS
"

export DELAYED_EVAL="
$DELAYED_EVAL
PROMETHEUS_LONGTERM_VERSION
PROMETHEUS_LONGTERM_DOCKER
PROMETHEUS_LONGTERM_IMAGE
PROMETHEUS_LONGTERM_RULES_FILE
"

COMPONENT_DEPENDENCIES="
./components/monitoring
"
# Note that this component does not depend explicitly on the `components/monitoring` component so that this can
# theoretically be deployed on a different machine than the `prometheus` service. This is currently untested.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ x-logging:

services:
prometheus-longterm-metrics:
image: ${PROMETHEUS_IMAGE}
image: ${PROMETHEUS_LONGTERM_IMAGE}
container_name: prometheus-longterm-metrics
volumes:
- ./optional-components/prometheus-longterm-metrics/prometheus.yml:/etc/prometheus/prometheus.yml:ro
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ scrape_configs:
- '{group="longterm-metrics"}'

static_configs:
- targets:
- 'prometheus:9090'
- targets: ${PROMETHEUS_LONGTERM_TARGETS}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: "3.4"

services:
prometheus:
volumes:
- ./optional-components/prometheus-longterm-rules/config/monitoring/prometheus.rules:/etc/prometheus/prometheus-longterm-metrics.rules:ro

0 comments on commit 2eab8b7

Please sign in to comment.