Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: adds an otelcollector example #2277

Open
wants to merge 4 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions examples/otelcollector/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Grafana Agent mull mode integration
knylander-grafana marked this conversation as resolved.
Show resolved Hide resolved

This example demonstrates how you can use Grafana Agent with Grafana Pyroscope to profile otel collector.

### 1. Configure Grafana agent

For Grafana Agent to pull profiles from your application, configure the agent for things like profiling configuration, targets, and possibly authentication.
knylander-grafana marked this conversation as resolved.
Show resolved Hide resolved

You can find a list of [arguments](https://grafana.com/docs/agent/next/flow/reference/components/pyroscope.scrape/#arguments) and [supported blocks](https://grafana.com/docs/agent/next/flow/reference/components/pyroscope.scrape/#blocks) in the [Grafana Agent documentation for Pyroscope](https://grafana.com/docs/agent/next/flow/reference/components/pyroscope.scrape/)

Refer to [config file](./agent/config/config.river) to see an example of how to configure Grafana Agent to send profiling data to Pyroscope.

### 2. Run Grafana agent, Grafana, and Pyroscope

```shell
docker-compose up -d
```

### 3. Observe profiling data

Now that everything is set up, you can browse profiling data via [Grafana UI](http://localhost:3000).

#### Explore view
For showing profiling data alongside traces
![image](https://github.com/grafana/pyroscope/assets/23323466/a9c2f28c-d35a-49b0-a3bc-678d3fbdd321)

#### Dashboard
For showing real-time overview of profiling data
![image](https://github.com/grafana/pyroscope/assets/23323466/59a84d0c-87d2-4cfc-8e34-b54576cb6540)

2 changes: 2 additions & 0 deletions examples/otelcollector/agent/config/agent.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
server:
log_level: info
28 changes: 28 additions & 0 deletions examples/otelcollector/agent/config/config.river
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
logging {
level = "debug"
format = "logfmt"
}

pyroscope.write "example" {
// Send metrics to a locally running Phlare instance.
endpoint {
url = "http://pyroscope:4040"

// To send data to Grafana Cloud you'll need to provide username and password.
// basic_auth {
// username = "myuser"
// password = "mypassword"
// }
}
external_labels = {
"env" = "example",
}
}


pyroscope.scrape "default" {
targets = [
{"__address__" = "otelcollector:6060", "service_name"="otelcollector"},
]
forward_to = [pyroscope.write.example.receiver]
}
41 changes: 41 additions & 0 deletions examples/otelcollector/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
version: '3.9'
services:
grafana:
image: grafana/grafana:latest
volumes:
- ./grafana-provisioning:/etc/grafana/provisioning
- ./grafana/grafana.ini:/etc/grafana/grafana.ini
- ./grafana/home.json:/default-dashboard.json
ports:
- 3000:3000

pyroscope:
image: 'grafana/pyroscope:1.0.0-rc.0'
ports:
- 4040:4040
command: -config.file=/etc/pyroscope/config.yaml
volumes:
- ./pyroscope/config.yaml:/etc/pyroscope/config.yaml

agent:
image: grafana/agent:latest
volumes:
- ./agent/config:/etc/agent-config
command:
- run
- /etc/agent-config/config.river
- --server.http.listen-addr=0.0.0.0:12345
environment:
HOSTNAME: agent
AGENT_MODE: flow
ports:
- "12345:12345"

otelcollector:
image: otel/opentelemetry-collector:0.67.0
restart: always
command: ["--config=/etc/otelcollector.yaml"]
volumes:
- ./otelcollector.yaml:/etc/otelcollector.yaml
ports:
- "6060:6060" # pprof extension
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"annotations": {
"list": []
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 1,
"links": [],
"liveNow": false,
"panels": [
{
"datasource": {
"type": "phlare",
"uid": "pyroscope"
},
"gridPos": {
"h": 19,
"w": 24,
"x": 0,
"y": 0
},
"id": 1,
"targets": [
{
"datasource": {
"type": "phlare",
"uid": "pyroscope"
},
"groupBy": [],
"labelSelector": "{}",
"profileTypeId": "process_cpu:cpu:nanoseconds:cpu:nanoseconds",
"queryType": "profile",
"refId": "A"
}
],
"title": "Panel Title",
"type": "flamegraph"
}
],
"refresh": "5s",
"schemaVersion": 38,
"style": "dark",
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "now-15m",
"to": "now"
},
"timepicker": {
"refresh_intervals": [
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
],
"time_options": ["5m", "15m", "1h", "6h", "12h", "24h", "2d", "7d", "30d"]
},
"timezone": "browser",
"title": "main",
"uid": "65gjqY3Mk",
"version": 1,
"weekStart": ""
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: 1

providers:
- name: dashboards
type: file
updateIntervalSeconds: 5
options:
path: /etc/grafana/provisioning/dashboards
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
apiVersion: 1
datasources:
- name: Pyroscope
orgId: 1
uid: pyroscope
type: 'phlare'
access: 'proxy'
grafanaOrgId: 1
url: http://pyroscope:4040
isDefault: true
editable: true
Loading
Loading