Skip to content
Merged
Show file tree
Hide file tree
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
41 changes: 33 additions & 8 deletions .github/workflows/test-remote-monitoring.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ on:
required: true
default: true
type: boolean
use_direct_scraping:
description: "Scrape Memgraph's OpenMetrics endpoint directly instead of via mg-exporter (requires Memgraph >= 3.11)."
required: false
default: false
Comment thread
as51340 marked this conversation as resolved.
type: boolean
pull_request:
branches:
- main
Expand All @@ -23,6 +28,12 @@ on:
- "scripts/verify-remote-monitoring.sh"
- ".github/workflows/test-remote-monitoring.yaml"

# Default to the mg-exporter scrape path (works with the released chart appVersion).
# Direct OpenMetrics scraping requires Memgraph >= 3.11, so it's a manual opt-in via
# use_direct_scraping=true; pull_request runs always use mg-exporter.
env:
USE_MG_EXPORTER: ${{ inputs.use_direct_scraping != true }}

jobs:
test-ha-remote-monitoring:
name: HA remote monitoring
Expand Down Expand Up @@ -81,10 +92,15 @@ jobs:

- name: Install HA chart with remote monitoring enabled
run: |
if [[ "${USE_MG_EXPORTER}" == "true" ]]; then
echo "Scrape path: mg-exporter"
SCRAPE_ARGS=(--set prometheus.enabled=true --set prometheus.namespace=monitoring --set prometheus.serviceMonitor.enabled=false)
else
echo "Scrape path: direct OpenMetrics"
SCRAPE_ARGS=(--set prometheus.enabled=false --set scrapeMemgraphDirectly=true)
fi
helm install memgraph-db ./charts/memgraph-high-availability \
--set prometheus.enabled=true \
--set prometheus.namespace=monitoring \
--set prometheus.serviceMonitor.enabled=false \
"${SCRAPE_ARGS[@]}" \
--set vmagentRemote.enabled=true \
--set vmagentRemote.namespace=monitoring \
--set vmagentRemote.remoteWrite.url=http://monitoring-gateway.remote-monitoring.svc.cluster.local/api/v1/write \
Expand All @@ -104,7 +120,9 @@ jobs:

- name: Wait for monitoring side components
run: |
kubectl rollout status deployment/mg-exporter -n monitoring --timeout=300s
if [[ "${USE_MG_EXPORTER}" == "true" ]]; then
kubectl rollout status deployment/mg-exporter -n monitoring --timeout=300s
fi
kubectl rollout status deployment/memgraph-db-memgraph-high-availability-vmagent -n monitoring --timeout=300s

- name: Verify metrics and logs reach monitoring cluster
Expand Down Expand Up @@ -174,13 +192,18 @@ jobs:

- name: Install standalone chart with remote monitoring enabled
run: |
if [[ "${USE_MG_EXPORTER}" == "true" ]]; then
echo "Scrape path: mg-exporter"
SCRAPE_ARGS=(--set prometheus.enabled=true --set prometheus.namespace=monitoring --set prometheus.serviceMonitor.enabled=false)
else
echo "Scrape path: direct OpenMetrics"
SCRAPE_ARGS=(--set prometheus.enabled=false --set scrapeMemgraphDirectly=true)
fi
helm install memgraph-db ./charts/memgraph \
--set service.enableHttpMonitoring=true \
--set service.enableWebsocketMonitoring=true \
--set-json 'memgraphConfig=["--data-directory=/var/lib/memgraph/mg_data","--also-log-to-stderr=true","--log-level=TRACE"]' \
--set prometheus.enabled=true \
--set prometheus.namespace=monitoring \
--set prometheus.serviceMonitor.enabled=false \
"${SCRAPE_ARGS[@]}" \
--set vmagentRemote.enabled=true \
--set vmagentRemote.namespace=monitoring \
--set vmagentRemote.remoteWrite.url=http://monitoring-gateway.remote-monitoring.svc.cluster.local/api/v1/write \
Expand All @@ -200,7 +223,9 @@ jobs:
- name: Wait for monitoring side components
run: |
kubectl rollout status statefulset/memgraph-db -n default --timeout=300s
kubectl rollout status deployment/mg-exporter -n monitoring --timeout=300s
if [[ "${USE_MG_EXPORTER}" == "true" ]]; then
kubectl rollout status deployment/mg-exporter -n monitoring --timeout=300s
fi
kubectl rollout status deployment/memgraph-db-vmagent -n monitoring --timeout=300s

- name: Verify metrics and logs reach monitoring cluster
Expand Down
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ Both Memgraph charts support optional remote observability:
This works with VictoriaMetrics/VictoriaLogs, and with other backends that expose compatible Prometheus remote-write and Loki endpoints.

### Prerequisites
- Enable chart-level Prometheus exporter (`prometheus.enabled=true`).
- Provide a metrics source for `vmagentRemote`, either:
- the chart-level Prometheus exporter (`prometheus.enabled=true`) — the default, or
- direct scraping of Memgraph's OpenMetrics endpoint (top-level `scrapeMemgraphDirectly=true`), which needs no exporter (`prometheus.enabled=false`). See [Scrape Memgraph directly](#scrape-memgraph-directly-without-mg-exporter).
- Use a secret containing credentials for your remote endpoints (required for `vmagentRemote`; optional for `vectorRemote`).
- For standalone chart, enable Memgraph monitoring ports:
- `service.enableHttpMonitoring=true`
Expand All @@ -106,6 +108,38 @@ This works with VictoriaMetrics/VictoriaLogs, and with other backends that expos
- HA chart: add `--monitoring-port=<vectorRemote.websocketPort>` and `--monitoring-address=0.0.0.0` to each instance's `args`
- If `vmagentRemote.enabled=true` and you only need remote_write, set `prometheus.serviceMonitor.enabled=false` to avoid duplicate scraping of `mg-exporter` by both vmagent and kube-prometheus.

### Scrape Memgraph directly (without mg-exporter)
By default `vmagentRemote` scrapes the `mg-exporter`, which requires `prometheus.enabled=true`. To scrape Memgraph's OpenMetrics endpoint directly instead — with no exporter deployed — set the top-level `scrapeMemgraphDirectly=true` and leave `prometheus.enabled=false`:

```yaml
# Top-level master switch: Memgraph serves OpenMetrics and all scrapers hit it directly.
scrapeMemgraphDirectly: true

prometheus:
enabled: false # mg-exporter not needed

vmagentRemote:
enabled: true
namespace: monitoring
remoteWrite:
url: "https://<prom-remote-write>/api/v1/write"
basicAuth:
secretName: monitoring-basic-auth
usernameKey: username
passwordKey: password
externalLabels:
cluster_id: "memgraph-ha"
service_name: "Memgraph HA"
cluster_env: "dev"
```

When `scrapeMemgraphDirectly=true`, the chart runs each instance with `--metrics-format=OpenMetrics` and exposes the metrics port automatically (for the standalone chart you do not need to set `service.enableHttpMonitoring`). All other `vmagentRemote` / `vectorRemote` settings are the same as the examples below. The metrics endpoint is served over plain HTTP.

### In-cluster scraping with kube-prometheus-stack
For an in-cluster Prometheus (e.g. `kube-prometheus-stack`), set `prometheus.serviceMonitor.enabled=true` to provision a `ServiceMonitor`. By default it scrapes the `mg-exporter`; set the top-level `scrapeMemgraphDirectly=true` to scrape Memgraph's OpenMetrics endpoint directly instead (no exporter; requires Memgraph >= 3.11). The same `scrapeMemgraphDirectly` switch governs both the in-cluster ServiceMonitor and the remote `vmagentRemote`.

Set `prometheus.grafanaDashboard.enabled=true` to ship the bundled "Memgraph OpenMetrics" dashboard as a ConfigMap (labelled `grafana_dashboard`) for the Grafana sidecar to auto-load. It uses a datasource template variable, so it binds to Grafana's default Prometheus. The ConfigMap must live in a namespace the sidecar watches — set `prometheus.grafanaDashboard.namespace` to Grafana's namespace (or run the sidecar with `searchNamespace: ALL`).

### Standalone chart example
```yaml
prometheus:
Expand Down
Loading
Loading