diff --git a/devenv/docker/blocks/self-instrumentation/agent.flow b/devenv/docker/blocks/self-instrumentation/agent.flow new file mode 100644 index 00000000000..18521ac1d49 --- /dev/null +++ b/devenv/docker/blocks/self-instrumentation/agent.flow @@ -0,0 +1,53 @@ +loki.write "default" { + endpoint { + url = "http://loki:3100/loki/api/v1/push" + } + external_labels = {} +} + +logging { + level = "debug" + format = "json" + write_to = [loki.write.default.receiver] +} + +tracing { + sampling_fraction = 1 + write_to = [otelcol.exporter.otlp.tempo.input] +} + +otelcol.exporter.otlp "tempo" { + client { + endpoint = "tempo:4317" + tls { + insecure = true + insecure_skip_verify = true + } + } +} + +faro.receiver "frontend" { + server { + listen_address = "0.0.0.0" + listen_port = 12347 + cors_allowed_origins = ["*"] + } + + output { + logs = [loki.write.default.receiver] + traces = [otelcol.exporter.otlp.tempo.input] + } +} + +pyroscope.write "default" { + endpoint { + url = "http://pyroscope:4040" + } +} + +pyroscope.scrape "default" { + targets = [ + {"__address__" = "host.docker.internal:6060", "service_name"="grafana"}, + ] + forward_to = [pyroscope.write.default.receiver] +} diff --git a/devenv/docker/blocks/self-instrumentation/agent.yaml b/devenv/docker/blocks/self-instrumentation/agent.yaml deleted file mode 100644 index aae89d2cd72..00000000000 --- a/devenv/docker/blocks/self-instrumentation/agent.yaml +++ /dev/null @@ -1,40 +0,0 @@ -logs: - positions_directory: /tmp/loki-pos - configs: - - name: default - scrape_configs: [] - clients: - - url: http://host.docker.internal:3100/loki/api/v1/push -traces: - configs: - - name: default - remote_write: - - endpoint: http://host.docker.internal:3200 - insecure: true - receivers: - otlp: - protocols: - grpc: - http: - cors: - allowed_origins: - - "*" -integrations: - app_agent_receiver_configs: - - autoscrape: - enable: false - instance: "frontend" - logs_instance: "default" - traces_instance: "default" - server: - host: 0.0.0.0 - port: 12347 - cors_allowed_origins: - - "*" - logs_labels: # labels to add to loki log record - app: frontend # static value - kind: # value will be taken from log items. exception, log, measurement, etc - logs_send_timeout: 5000 - sourcemaps: - download: true # will download source file, extract source map location, - # download source map and use it to transform stack trace locations diff --git a/devenv/docker/blocks/self-instrumentation/docker-compose.yaml b/devenv/docker/blocks/self-instrumentation/docker-compose.yaml index cbd2f3f76b3..1806e0a92ab 100644 --- a/devenv/docker/blocks/self-instrumentation/docker-compose.yaml +++ b/devenv/docker/blocks/self-instrumentation/docker-compose.yaml @@ -30,15 +30,22 @@ ports: - "14268:14268" - "3200:3200" + - "4317:4317" + pyroscope: + image: "grafana/pyroscope:latest" + ports: + - "4040:4040" agent: - image: grafana/agent:v0.34.3 + image: grafana/agent:v0.37.0 + environment: + - AGENT_MODE=flow entrypoint: - /bin/grafana-agent - - -server.http.address=0.0.0.0:12345 - - -config.file=/etc/agent/agent.yaml - - -enable-features=integrations-next + - run + - --server.http.listen-addr=0.0.0.0:12345 + - /etc/agent/config.river volumes: - - ./docker/blocks/self-instrumentation/agent.yaml:/etc/agent/agent.yaml + - ./docker/blocks/self-instrumentation/agent.flow:/etc/agent/config.river ports: - "12345:12345" - "12347:12347" diff --git a/devenv/docker/blocks/self-instrumentation/promtail.yaml b/devenv/docker/blocks/self-instrumentation/promtail.yaml index e3ceb813909..eb7787ef789 100644 --- a/devenv/docker/blocks/self-instrumentation/promtail.yaml +++ b/devenv/docker/blocks/self-instrumentation/promtail.yaml @@ -9,10 +9,10 @@ clients: - url: http://loki:3100/loki/api/v1/push scrape_configs: -- job_name: hosted-grafana/grafana +- job_name: grafana static_configs: - targets: - localhost labels: - job: hosted-grafana/grafana + job: grafana __path__: /var/log/grafana/*log diff --git a/devenv/docker/blocks/self-instrumentation/readme.md b/devenv/docker/blocks/self-instrumentation/readme.md index eb2a918ec83..76ef72d1ed4 100644 --- a/devenv/docker/blocks/self-instrumentation/readme.md +++ b/devenv/docker/blocks/self-instrumentation/readme.md @@ -6,14 +6,26 @@ To run this source, in the Grafana repo root: make devenv sources=self-instrumentation ``` -This will setup Prometheus, Loki and Tempo. +This will setup Prometheus, Loki, Tempo, and Pyroscope. You then need to run Grafana with those added config: ```ini +[log.file] +format = json + [log.frontend] enabled = true +custom_endpoint=http://localhost:12347/collect [tracing.opentelemetry.jaeger] address = http://localhost:14268/api/traces -``` \ No newline at end of file +``` + +To collect profiles with pyroscope, you need to run Grafana with the following env vars: + +```bash +export GF_DIAGNOSTICS_PROFILING_ENABLED=true +export GF_DIAGNOSTICS_PROFILING_ADDR=0.0.0.0 +make run +``````