From 7df2b86372b18ba9eeb07ffe87f17e80a04e26d4 Mon Sep 17 00:00:00 2001 From: Hank Donnay Date: Fri, 7 Jul 2023 11:49:07 -0500 Subject: [PATCH] chore: add pyroscope to compose setup The `debug` profile will now also start a pyroscope instance configured to scrape the indexer and matcher. Signed-off-by: Hank Donnay --- docker-compose.yaml | 27 +++++++++++---- .../provisioning/datasources/datasource.yml | 34 +++++-------------- local-dev/pyroscope/server.yml | 19 +++++++++++ local-dev/traefik/config/pyroscope.yaml | 21 ++++++++++++ 4 files changed, 70 insertions(+), 31 deletions(-) create mode 100644 local-dev/pyroscope/server.yml create mode 100644 local-dev/traefik/config/pyroscope.yaml diff --git a/docker-compose.yaml b/docker-compose.yaml index d12de79536..7ccb4a9ba6 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -3,17 +3,18 @@ version: "3.7" # This is just to hold a bunch of yaml anchors and try to consolidate parts of # the config. x-anchors: - postgres: &postgres-image docker.io/library/postgres:12 - traefik: &traefik-image docker.io/library/traefik:v2.2 - pgadmin: &pgadmin-image docker.io/dpage/pgadmin4:5.7 + go: &go-image quay.io/projectquay/golang:1.20 + grafana: &grafana-image docker.io/grafana/grafana:8.0.3 jaeger: &jaeger-image docker.io/jaegertracing/all-in-one:1.26 + pgadmin: &pgadmin-image docker.io/dpage/pgadmin4:5.7 + postgres: &postgres-image docker.io/library/postgres:12 prom: &prom-image docker.io/prom/prometheus:v2.30.2 - grafana: &grafana-image docker.io/grafana/grafana:8.0.3 + pyroscope: &pyroscope-image docker.io/pyroscope/pyroscope:0.37.2 quay: &quay-image quay.io/projectquay/quay:latest + rabbitmq: &rabbitmq-image docker.io/library/rabbitmq:3.11 redis: &redis-image docker.io/library/redis:6.2 - go: &go-image quay.io/projectquay/golang:1.20 skopeo: &skopeo-image quay.io/skopeo/stable:latest - rabbitmq: &rabbitmq-image docker.io/library/rabbitmq:3.11 + traefik: &traefik-image docker.io/library/traefik:v2.2 clair-service: &clair-service image: *go-image depends_on: @@ -110,6 +111,18 @@ services: - '--web.external-url=http://localhost:8080/prom/' - '--web.console.libraries=/usr/share/prometheus/console_libraries' - '--web.console.templates=/usr/share/prometheus/consoles' + pyroscope: + container_name: clair-pyroscope + profiles: + - debug + image: *pyroscope-image + volumes: + - ./local-dev/pyroscope:/etc/pyroscope/ + command: + - server + environment: + PYROSCOPE_LOG_LEVEL: info + PYROSCOPE_WAIT_AFTER_STOP: 'true' grafana: container_name: clair-grafana profiles: @@ -119,10 +132,12 @@ services: environment: GF_SERVER_ROOT_URL: /grafana GF_SERVER_SERVE_FROM_SUB_PATH: 'true' + GF_INSTALL_PLUGINS: 'pyroscope-datasource,pyroscope-panel' volumes: - ./local-dev/grafana/provisioning/:/etc/grafana/provisioning/ depends_on: - prometheus + - pyroscope # Notifier services -- use profile 'notifier' notifier: ¬ifier diff --git a/local-dev/grafana/provisioning/datasources/datasource.yml b/local-dev/grafana/provisioning/datasources/datasource.yml index 5f28aa04d0..79940f13b8 100644 --- a/local-dev/grafana/provisioning/datasources/datasource.yml +++ b/local-dev/grafana/provisioning/datasources/datasource.yml @@ -1,3 +1,4 @@ +--- # config file version apiVersion: 1 @@ -19,32 +20,15 @@ datasources: orgId: 1 # url url: http://clair-prometheus:9090/prom/ - # database password, if used - password: - # database user, if used - user: - # database name, if used - database: - # enable/disable basic auth - basicAuth: false - # basic auth username, if used - basicAuthUser: - # basic auth password, if used - basicAuthPassword: - # enable/disable with credentials headers - withCredentials: # mark as default datasource. Max one per org isDefault: true - # fields that will be converted to json and stored in json_data - jsonData: - graphiteVersion: "1.1" - tlsAuth: false - tlsAuthWithCACert: false - # json object of data that will be encrypted. - secureJsonData: - tlsCACert: "..." - tlsClientCert: "..." - tlsClientKey: "..." version: 1 - # allow users to edit datasources from the UI. + editable: false +- name: Pyroscope + type: pyroscope-datasource + access: proxy + orgId: 1 + url: http://clair-pyroscope:4040/ + jsonData: + path: http://clair-pyroscope:4040/ editable: false diff --git a/local-dev/pyroscope/server.yml b/local-dev/pyroscope/server.yml new file mode 100644 index 0000000000..c1896be574 --- /dev/null +++ b/local-dev/pyroscope/server.yml @@ -0,0 +1,19 @@ +--- +analytics-opt-out: 'true' +base-url: /pyroscope +disable-pprof-endpoint: 'true' +scrape-configs: +- job-name: pyroscope + scrape-interval: 10s + scrape-timeout: 15s + enabled-profiles: [cpu, mem, goroutines, mutex, block] + use-delta-profiles: true + static-configs: + - application: clair-indexer + spy-name: gospy + targets: + - clair-indexer:8089 + - application: clair-matcher + spy-name: gospy + targets: + - clair-matcher:8089 diff --git a/local-dev/traefik/config/pyroscope.yaml b/local-dev/traefik/config/pyroscope.yaml new file mode 100644 index 0000000000..5dc644d2f6 --- /dev/null +++ b/local-dev/traefik/config/pyroscope.yaml @@ -0,0 +1,21 @@ +--- +http: + routers: + pyroscope: + entryPoints: [traefik] + rule: 'PathPrefix(`/pyroscope`)' + service: pyroscope + middlewares: + - pyroscope-stripprefix + middlewares: + pyroscope-stripprefix: + stripPrefix: + prefixes: + - /pyroscope + services: + pyroscope: + loadBalancer: + servers: + - url: "http://clair-pyroscope:4040/" + healthCheck: + path: /