DevEnv: Add pyroscope to self-instrumentation (#78430)

This commit is contained in:
Todd Treece 2024-01-02 15:35:59 -05:00 committed by GitHub
parent 2502fe4d19
commit a5957ba555
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 81 additions and 49 deletions

View File

@ -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]
}

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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
```
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
``````