feat(metrics): lab7 secure Prometheus scraping and queries
This commit is contained in:
+28
-1
@@ -1,4 +1,4 @@
|
|||||||
name: golikovap-messenger-lab7
|
name: golikovap-messenger-lab6
|
||||||
|
|
||||||
x-api-resources: &api-resources
|
x-api-resources: &api-resources
|
||||||
limits:
|
limits:
|
||||||
@@ -407,10 +407,17 @@ services:
|
|||||||
image: prom/prometheus:v3.16.0
|
image: prom/prometheus:v3.16.0
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
command:
|
command:
|
||||||
|
- --web.config.file=/etc/prometheus/web.yml
|
||||||
- --config.file=/etc/prometheus/prometheus.yml
|
- --config.file=/etc/prometheus/prometheus.yml
|
||||||
- --storage.tsdb.path=/prometheus
|
- --storage.tsdb.path=/prometheus
|
||||||
- --storage.tsdb.retention.time=7d
|
- --storage.tsdb.retention.time=7d
|
||||||
volumes:
|
volumes:
|
||||||
|
- ./certs/private/ingress/ca.crt:/tls/ca.crt:ro
|
||||||
|
- ./certs/private/telemetry/prometheus-client.crt:/tls/client.crt:ro
|
||||||
|
- ./certs/private/telemetry/prometheus-client.key:/tls/client.key:ro
|
||||||
|
- ./certs/private/telemetry/prometheus-server.crt:/tls/server.crt:ro
|
||||||
|
- ./certs/private/telemetry/prometheus-server.key:/tls/server.key:ro
|
||||||
|
- ./infra/telemetry/prometheus-web.yml:/etc/prometheus/web.yml:ro
|
||||||
- ./infra/prometheus.yml:/etc/prometheus/prometheus.yml:ro
|
- ./infra/prometheus.yml:/etc/prometheus/prometheus.yml:ro
|
||||||
- ./infra/prometheus/rules:/etc/prometheus/rules:ro
|
- ./infra/prometheus/rules:/etc/prometheus/rules:ro
|
||||||
- prometheus_data:/prometheus
|
- prometheus_data:/prometheus
|
||||||
@@ -489,6 +496,26 @@ services:
|
|||||||
- ./certs/private/telemetry/otel-collector-server.key:/tls/server.key:ro
|
- ./certs/private/telemetry/otel-collector-server.key:/tls/server.key:ro
|
||||||
- ./infra/telemetry/otel-collector-tls.conf:/etc/nginx/nginx.conf:ro
|
- ./infra/telemetry/otel-collector-tls.conf:/etc/nginx/nginx.conf:ro
|
||||||
|
|
||||||
|
rabbitmq-tls:
|
||||||
|
image: nginx:1.27.4-alpine
|
||||||
|
restart: unless-stopped
|
||||||
|
network_mode: "service:rabbitmq"
|
||||||
|
volumes:
|
||||||
|
- ./certs/private/ingress/ca.crt:/tls/ca.crt:ro
|
||||||
|
- ./certs/private/telemetry/rabbitmq-server.crt:/tls/server.crt:ro
|
||||||
|
- ./certs/private/telemetry/rabbitmq-server.key:/tls/server.key:ro
|
||||||
|
- ./infra/telemetry/rabbitmq-tls.conf:/etc/nginx/nginx.conf:ro
|
||||||
|
|
||||||
|
grafana-datasources:
|
||||||
|
image: nginx:1.27.4-alpine
|
||||||
|
restart: unless-stopped
|
||||||
|
network_mode: "service:grafana"
|
||||||
|
volumes:
|
||||||
|
- ./certs/private/ingress/ca.crt:/tls/ca.crt:ro
|
||||||
|
- ./certs/private/telemetry/grafana-client.crt:/tls/client.crt:ro
|
||||||
|
- ./certs/private/telemetry/grafana-client.key:/tls/client.key:ro
|
||||||
|
- ./infra/telemetry/grafana-datasources.conf:/etc/nginx/nginx.conf:ro
|
||||||
|
|
||||||
secrets:
|
secrets:
|
||||||
rabbit_api:
|
rabbit_api:
|
||||||
file: ./certs/private/rabbitmq/api.url
|
file: ./certs/private/rabbitmq/api.url
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ datasources:
|
|||||||
uid: prometheus
|
uid: prometheus
|
||||||
type: prometheus
|
type: prometheus
|
||||||
access: proxy
|
access: proxy
|
||||||
url: http://prometheus:9090
|
url: http://127.0.0.1:9090
|
||||||
isDefault: true
|
isDefault: true
|
||||||
editable: false
|
editable: false
|
||||||
jsonData:
|
jsonData:
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ processors:
|
|||||||
|
|
||||||
exporters:
|
exporters:
|
||||||
prometheus:
|
prometheus:
|
||||||
endpoint: 0.0.0.0:9464
|
endpoint: 127.0.0.1:19464
|
||||||
add_metric_suffixes: false
|
add_metric_suffixes: false
|
||||||
resource_to_telemetry_conversion:
|
resource_to_telemetry_conversion:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|||||||
@@ -7,6 +7,11 @@ rule_files:
|
|||||||
|
|
||||||
scrape_configs:
|
scrape_configs:
|
||||||
- job_name: otel-collector
|
- job_name: otel-collector
|
||||||
|
scheme: https
|
||||||
|
tls_config:
|
||||||
|
ca_file: /tls/ca.crt
|
||||||
|
cert_file: /tls/client.crt
|
||||||
|
key_file: /tls/client.key
|
||||||
static_configs:
|
static_configs:
|
||||||
- targets: ["otel-collector:9464"]
|
- targets: ["otel-collector:9464"]
|
||||||
|
|
||||||
@@ -15,5 +20,10 @@ scrape_configs:
|
|||||||
params:
|
params:
|
||||||
vhost: ["/"]
|
vhost: ["/"]
|
||||||
family: [queue_coarse_metrics, queue_metrics]
|
family: [queue_coarse_metrics, queue_metrics]
|
||||||
|
scheme: https
|
||||||
|
tls_config:
|
||||||
|
ca_file: /tls/ca.crt
|
||||||
|
cert_file: /tls/client.crt
|
||||||
|
key_file: /tls/client.key
|
||||||
static_configs:
|
static_configs:
|
||||||
- targets: ["rabbitmq:15692"]
|
- targets: ["rabbitmq:15692"]
|
||||||
|
|||||||
@@ -8,3 +8,5 @@ ssl_options.fail_if_no_peer_cert = false
|
|||||||
management.tcp.ip = 127.0.0.1
|
management.tcp.ip = 127.0.0.1
|
||||||
definitions.import_backend = local_filesystem
|
definitions.import_backend = local_filesystem
|
||||||
definitions.local.path = /run/broker/definitions.json
|
definitions.local.path = /run/broker/definitions.json
|
||||||
|
prometheus.tcp.ip = 127.0.0.1
|
||||||
|
prometheus.tcp.port = 15693
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
worker_processes 1;
|
||||||
|
events { worker_connections 512; }
|
||||||
|
http {
|
||||||
|
access_log off;
|
||||||
|
ssl_protocols TLSv1.2 TLSv1.3;
|
||||||
|
client_max_body_size 16m;
|
||||||
|
resolver 127.0.0.11 valid=10s ipv6=off;
|
||||||
|
server {
|
||||||
|
listen 127.0.0.1:9090;
|
||||||
|
location / {
|
||||||
|
set $target "prometheus:9090";
|
||||||
|
proxy_ssl_verify on;
|
||||||
|
proxy_ssl_server_name on;
|
||||||
|
proxy_ssl_name prometheus;
|
||||||
|
proxy_ssl_trusted_certificate /tls/ca.crt;
|
||||||
|
proxy_ssl_certificate /tls/client.crt;
|
||||||
|
proxy_ssl_certificate_key /tls/client.key;
|
||||||
|
proxy_pass https://$target;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,4 +17,17 @@ http {
|
|||||||
}
|
}
|
||||||
location / { return 403; }
|
location / { return 403; }
|
||||||
}
|
}
|
||||||
}
|
server {
|
||||||
|
listen 9464 ssl;
|
||||||
|
ssl_certificate /tls/server.crt;
|
||||||
|
ssl_certificate_key /tls/server.key;
|
||||||
|
ssl_client_certificate /tls/ca.crt;
|
||||||
|
ssl_verify_client on;
|
||||||
|
if ($ssl_client_s_dn !~ "^CN=lab7-telemetry-(prometheus)$") { return 403; }
|
||||||
|
location = /metrics {
|
||||||
|
limit_except GET { deny all; }
|
||||||
|
proxy_pass http://127.0.0.1:19464;
|
||||||
|
}
|
||||||
|
location / { return 403; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
tls_server_config:
|
||||||
|
cert_file: /tls/server.crt
|
||||||
|
key_file: /tls/server.key
|
||||||
|
client_ca_file: /tls/ca.crt
|
||||||
|
client_auth_type: RequireAndVerifyClientCert
|
||||||
|
client_allowed_sans:
|
||||||
|
- lab7-telemetry-grafana
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
worker_processes 1;
|
||||||
|
events { worker_connections 512; }
|
||||||
|
http {
|
||||||
|
access_log off;
|
||||||
|
ssl_protocols TLSv1.2 TLSv1.3;
|
||||||
|
client_max_body_size 16m;
|
||||||
|
server {
|
||||||
|
listen 15692 ssl;
|
||||||
|
ssl_certificate /tls/server.crt;
|
||||||
|
ssl_certificate_key /tls/server.key;
|
||||||
|
ssl_client_certificate /tls/ca.crt;
|
||||||
|
ssl_verify_client on;
|
||||||
|
if ($ssl_client_s_dn !~ "^CN=lab7-telemetry-(prometheus)$") { return 403; }
|
||||||
|
location = /metrics/detailed {
|
||||||
|
limit_except GET { deny all; }
|
||||||
|
proxy_pass http://127.0.0.1:15693;
|
||||||
|
}
|
||||||
|
location / { return 403; }
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user