Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

monitoring: add postgres_exporter process to dev and single server #6616

Merged
merged 3 commits into from
Nov 15, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions cmd/server/Dockerfile
Original file line number Diff line number Diff line change
@@ -69,15 +69,18 @@ RUN set -ex && \
apk add --no-cache libc6-compat=1.1.24-r0 ca-certificates su-exec

# hadolint ignore=DL3022
COPY --from=sourcegraph/grafana:10.0.4@sha256:ba3742bb63787d23664ace0b0b84e6e486d73c925f5870d92845f1f86eb7918d /usr/share/grafana /usr/share/grafana
COPY --from=sourcegraph/grafana:10.0.5@sha256:bd332c36c5aa36942f502d8078e2b7d57eaf0fa945380fe43c30fcfc902f91bd /usr/share/grafana /usr/share/grafana

# hadolint ignore=DL3022
COPY --from=libsqlite3-pcre /sqlite3-pcre/pcre.so /libsqlite3-pcre.so
ENV LIBSQLITE3_PCRE /libsqlite3-pcre.so
COPY . /

# hadolint ignore=DL3022
COPY --from=sourcegraph/grafana:10.0.4@sha256:ba3742bb63787d23664ace0b0b84e6e486d73c925f5870d92845f1f86eb7918d /sg_config_grafana/provisioning/dashboards/sourcegraph/*json /sg_config_grafana/provisioning/dashboards/sourcegraph/
COPY --from=sourcegraph/grafana:10.0.5@sha256:bd332c36c5aa36942f502d8078e2b7d57eaf0fa945380fe43c30fcfc902f91bd /sg_config_grafana/provisioning/dashboards/sourcegraph/*json /sg_config_grafana/provisioning/dashboards/sourcegraph/

# hadolint ignore=DL3022
COPY --from=wrouesnel/postgres_exporter:v0.7.0@sha256:785c919627c06f540d515aac88b7966f352403f73e931e70dc2cbf783146a98b /postgres_exporter /usr/local/bin/postgres_exporter

RUN echo "hosts: files dns" > /etc/nsswitch.conf

1 change: 1 addition & 0 deletions cmd/server/shared/shared.go
Original file line number Diff line number Diff line change
@@ -141,6 +141,7 @@ func Main() {
`syntect_server: sh -c 'env QUIET=true ROCKET_ENV=production ROCKET_PORT=9238 ROCKET_LIMITS='"'"'{json=10485760}'"'"' ROCKET_SECRET_KEY='"'"'SeerutKeyIsI7releuantAndknvsuZPluaseIgnorYA='"'"' ROCKET_KEEP_ALIVE=0 ROCKET_ADDRESS='"'"'"127.0.0.1"'"'"' syntect_server | grep -v "Rocket has launched" | grep -v "Warning: environment is"' | grep -v 'Configured for production'`,
`prometheus: prometheus --config.file=/sg_config_prometheus/prometheus.yml --storage.tsdb.path=/var/opt/sourcegraph/prometheus --web.console.libraries=/usr/share/prometheus/console_libraries --web.console.templates=/usr/share/prometheus/consoles >> /var/opt/sourcegraph/prometheus.log 2>&1`,
`grafana: /usr/share/grafana/bin/grafana-server -config /sg_config_grafana/grafana-single-container.ini -homepath /usr/share/grafana >> /var/opt/sourcegraph/grafana.log 2>&1`,
`postgres_exporter: env DATA_SOURCE_NAME="postgresql://postgres:sourcegraphd@127.0.0.1:5432/postgres?sslmode=disable" postgres_exporter`,
}
procfile = append(procfile, ProcfileAdditions...)

1 change: 1 addition & 0 deletions dev/Procfile
Original file line number Diff line number Diff line change
@@ -23,3 +23,4 @@ lsif-server: yarn --cwd lsif run run:server
lsif-worker: yarn --cwd lsif run run:worker
prometheus: ./dev/prometheus.sh
grafana: ./dev/grafana.sh
postgres_exporter: ./dev/postgres_exporter.sh
2 changes: 1 addition & 1 deletion dev/grafana.sh
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

GRAFANA_DISK="${HOME}/.sourcegraph-dev/data/grafana"

IMAGE=sourcegraph/grafana:10.0.4
IMAGE=sourcegraph/grafana:10.0.5
CONTAINER=grafana

mkdir -p ${GRAFANA_DISK}/logs
19 changes: 19 additions & 0 deletions dev/postgres_exporter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

# Description: Prometheus collects metrics and aggregates them into graphs.
#

set -euf -o pipefail

IMAGE=wrouesnel/postgres_exporter:v0.7.0@sha256:785c919627c06f540d515aac88b7966f352403f73e931e70dc2cbf783146a98b
CONTAINER=postgres_exporter

NET_ARG=""
DATA_SOURCE_NAME="postgresql://sourcegraph:sourcegraphd@host.docker.internal:5432/postgres?sslmode=disable"

if [[ "$OSTYPE" == "linux-gnu" ]]; then
NET_ARG="--net=host"
DATA_SOURCE_NAME="postgresql://sourcegraph:sourcegraphd@127.0.0.1:5432/postgres?sslmode=disable"
fi

exec docker run --rm -p9187:9187 ${NET_ARG} --name=postgres_exporter -e DATA_SOURCE_NAME=${DATA_SOURCE_NAME} ${IMAGE}
6 changes: 6 additions & 0 deletions dev/prometheus/all/prometheus_targets.yml
Original file line number Diff line number Diff line change
@@ -44,3 +44,9 @@
targets:
# lsif-worker
- host.docker.internal:3187
- labels:
job: postgres_exporter
targets:
# postgres exporter
- host.docker.internal:9187

5 changes: 5 additions & 0 deletions dev/prometheus/linux/prometheus_targets.yml
Original file line number Diff line number Diff line change
@@ -44,3 +44,8 @@
targets:
# lsif-worker
- 127.0.0.1:3187
- labels:
job: postgres_exporter
targets:
# postgres exporter
- 127.0.0.1:9187
1,964 changes: 1,964 additions & 0 deletions docker-images/grafana/config/provisioning/dashboards/sourcegraph/postgres.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docker-images/grafana/version.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
echo "10.0.4"
echo "10.0.5"