diff --git a/compose.base.yaml b/compose.base.yaml new file mode 100644 index 0000000..4b407ca --- /dev/null +++ b/compose.base.yaml @@ -0,0 +1,58 @@ +services: + ndc-prometheus: + build: + context: . + ports: + - 8080:8080 + volumes: + - ./tests/configuration:/etc/connector:ro + extra_hosts: + - local.hasura.dev=host-gateway + environment: + CONNECTION_URL: http://prometheus:9090 + PROMETHEUS_USERNAME: admin + PROMETHEUS_PASSWORD: test + OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: http://jaeger:4317 + OTEL_METRICS_EXPORTER: prometheus + HASURA_LOG_LEVEL: debug + + prometheus: + image: prom/prometheus:v2.54.1 + volumes: + - ./tests/prometheus/:/etc/prometheus/ + command: + - "--config.file=/etc/prometheus/prometheus.yml" + - "--storage.tsdb.path=/prometheus" + - "--web.console.libraries=/usr/share/prometheus/console_libraries" + - "--web.console.templates=/usr/share/prometheus/consoles" + - "--web.enable-lifecycle" + - "--web.config.file=/etc/prometheus/web.yml" + - "--enable-feature=promql-experimental-functions" + ports: + - 9090:9090 + links: + - alertmanager:alertmanager + restart: always + + node-exporter: + image: prom/node-exporter:v1.8.1 + volumes: + - /proc:/host/proc:ro + - /sys:/host/sys:ro + - /:/rootfs:ro + command: + - "--path.procfs=/host/proc" + - "--path.sysfs=/host/sys" + - --collector.filesystem.ignored-mount-points + - "^/(sys|proc|dev|host|etc|rootfs/var/lib/docker/containers|rootfs/var/lib/docker/overlay2|rootfs/run/docker/netns|rootfs/var/lib/docker/aufs)($$|/)" + ports: + - 9100:9100 + restart: always + + alertmanager: + image: prom/alertmanager:v0.27.0 + ports: + - 9093:9093 + volumes: + - ./tests/alertmanager/config.yml/:/etc/alertmanager/alertmanager.yml + restart: always diff --git a/compose.yaml b/compose.yaml index a46f776..1e94a21 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,64 +1,7 @@ include: + - path: ./compose.base.yaml - path: ./tests/engine/compose.yaml services: - ndc-prometheus: - build: - context: . - ports: - - 8080:8080 - volumes: - - ./tests/configuration:/etc/connector:ro - extra_hosts: - - local.hasura.dev=host-gateway - environment: - CONNECTION_URL: http://prometheus:9090 - PROMETHEUS_USERNAME: admin - PROMETHEUS_PASSWORD: test - OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: http://jaeger:4317 - OTEL_METRICS_EXPORTER: prometheus - HASURA_LOG_LEVEL: debug - - prometheus: - image: prom/prometheus:v2.54.1 - volumes: - - ./tests/prometheus/:/etc/prometheus/ - command: - - "--config.file=/etc/prometheus/prometheus.yml" - - "--storage.tsdb.path=/prometheus" - - "--web.console.libraries=/usr/share/prometheus/console_libraries" - - "--web.console.templates=/usr/share/prometheus/consoles" - - "--web.enable-lifecycle" - - "--web.config.file=/etc/prometheus/web.yml" - - "--enable-feature=promql-experimental-functions" - ports: - - 9090:9090 - links: - - alertmanager:alertmanager - restart: always - - node-exporter: - image: prom/node-exporter:v1.8.1 - volumes: - - /proc:/host/proc:ro - - /sys:/host/sys:ro - - /:/rootfs:ro - command: - - "--path.procfs=/host/proc" - - "--path.sysfs=/host/sys" - - --collector.filesystem.ignored-mount-points - - "^/(sys|proc|dev|host|etc|rootfs/var/lib/docker/containers|rootfs/var/lib/docker/overlay2|rootfs/run/docker/netns|rootfs/var/lib/docker/aufs)($$|/)" - ports: - - 9100:9100 - restart: always - - alertmanager: - image: prom/alertmanager:v0.27.0 - ports: - - 9093:9093 - volumes: - - ./tests/alertmanager/config.yml/:/etc/alertmanager/alertmanager.yml - restart: always - jaeger: image: jaegertracing/all-in-one:1.60 restart: always diff --git a/connector/testdata/query/prometheus_alertmanagers/expected.json b/connector/testdata/query/prometheus_alertmanagers/expected.json deleted file mode 100644 index 3be15c5..0000000 --- a/connector/testdata/query/prometheus_alertmanagers/expected.json +++ /dev/null @@ -1,16 +0,0 @@ -[ - { - "rows": [ - { - "__value": { - "activeAlertManagers": [ - { - "url": "http://alertmanager:9093/api/v2/alerts" - } - ], - "droppedAlertManagers": [] - } - } - ] - } -] diff --git a/connector/testdata/query/prometheus_label_names/expected.json b/connector/testdata/query/prometheus_label_names/expected.json index 498678e..f802b07 100644 --- a/connector/testdata/query/prometheus_label_names/expected.json +++ b/connector/testdata/query/prometheus_label_names/expected.json @@ -2,7 +2,7 @@ { "rows": [ { - "__value": ["__name__", "instance", "job"] + "__value": [] } ] } diff --git a/connector/testdata/query/prometheus_label_names/request.json b/connector/testdata/query/prometheus_label_names/request.json index 883e2a1..9f13592 100644 --- a/connector/testdata/query/prometheus_label_names/request.json +++ b/connector/testdata/query/prometheus_label_names/request.json @@ -11,6 +11,10 @@ "start": { "type": "literal", "value": "1970-01-01T00:00:01Z" + }, + "end": { + "type": "literal", + "value": "1970-01-02T00:00:01Z" } }, "collection": "prometheus_label_names", diff --git a/connector/testdata/query/prometheus_label_values/expected.json b/connector/testdata/query/prometheus_label_values/expected.json index 2581799..f802b07 100644 --- a/connector/testdata/query/prometheus_label_values/expected.json +++ b/connector/testdata/query/prometheus_label_values/expected.json @@ -2,7 +2,7 @@ { "rows": [ { - "__value": ["ndc-prometheus", "node"] + "__value": [] } ] } diff --git a/connector/testdata/query/prometheus_label_values/request.json b/connector/testdata/query/prometheus_label_values/request.json index 5a5ff00..dc2a8b3 100644 --- a/connector/testdata/query/prometheus_label_values/request.json +++ b/connector/testdata/query/prometheus_label_values/request.json @@ -11,6 +11,10 @@ "start": { "type": "literal", "value": "1970-01-01T00:00:01Z" + }, + "end": { + "type": "literal", + "value": "1970-01-02T00:00:01Z" } }, "collection": "prometheus_label_values", diff --git a/scripts/test.sh b/scripts/test.sh index 08328c8..160db6e 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -27,7 +27,7 @@ http_wait() { exit 1 } -docker compose up -d prometheus node-exporter alertmanager ndc-prometheus +docker compose -f ./compose.base.yaml up -d prometheus node-exporter alertmanager ndc-prometheus http_wait http://localhost:8080/health http_wait http://admin:test@localhost:9090/-/healthy