Skip to content

Commit 6083291

Browse files
authored
feat: Configure Grafana Alloy to receive OpenTelemetry data (#14)
1 parent 143f7e6 commit 6083291

20 files changed

+481
-295
lines changed

.github/workflows/tests.yml

Lines changed: 17 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: tests
22
on:
33
pull_request:
44
push:
5-
branches: [main]
5+
branches: [ main ]
66

77
schedule:
8-
- cron: '25 08 * * *'
8+
- cron: '25 08 * * *'
99

1010
workflow_dispatch:
1111
inputs:
@@ -15,78 +15,30 @@ on:
1515
required: false
1616
default: false
1717

18-
# This is required for "gautamkrishnar/keepalive-workflow"
19-
permissions:
20-
contents: write
21-
22-
defaults:
23-
run:
24-
shell: bash
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.ref }}
20+
cancel-in-progress: true
2521

26-
env:
27-
NIGHTLY_DDEV_PR_URL: 'https://nightly.link/ddev/ddev/actions/runs/1720215802/ddev-linux-amd64.zip'
28-
# Allow ddev get to use a github token to prevent rate limiting by tests
29-
DDEV_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30-
# Allow `--HEAD` flag when running tests against HEAD
31-
HOMEBREW_NO_INSTALL_FROM_API: 1
22+
# This is required for "gautamkrishnar/keepalive-workflow", see "ddev/github-action-add-on-test"
23+
permissions:
24+
actions: write
3225

3326
jobs:
3427
tests:
35-
defaults:
36-
run:
37-
shell: bash
38-
3928
strategy:
4029
matrix:
4130
ddev_version: [stable, HEAD]
42-
# ddev_version: [stable, edge, HEAD, PR]
4331
fail-fast: false
32+
# Disable parallel execution because of the issues with mounted volumes.
33+
max-parallel: 1
4434

45-
runs-on: ubuntu-20.04
35+
runs-on: ubuntu-latest
4636

4737
steps:
48-
- uses: actions/checkout@v3
49-
- name: Set up Homebrew
50-
id: set-up-homebrew
51-
uses: Homebrew/actions/setup-homebrew@master
52-
- name: Environment setup
53-
run: |
54-
brew install bats-core mkcert
55-
mkcert -install
56-
57-
- name: Use ddev stable
58-
if: matrix.ddev_version == 'stable'
59-
run: brew install ddev/ddev/ddev
60-
61-
- name: Use ddev edge
62-
if: matrix.ddev_version == 'edge'
63-
run: brew install ddev/ddev-edge/ddev
64-
65-
- name: Use ddev HEAD
66-
if: matrix.ddev_version == 'HEAD'
67-
run: brew install --HEAD ddev/ddev/ddev
68-
69-
- name: Use ddev PR
70-
if: matrix.ddev_version == 'PR'
71-
run: |
72-
curl -sSL -o ddev_linux.zip ${NIGHTLY_DDEV_PR_URL}
73-
unzip ddev_linux.zip
74-
mv ddev /usr/local/bin/ddev && chmod +x /usr/local/bin/ddev
75-
76-
- name: Download docker images
77-
run: mkdir junk && pushd junk && ddev config --auto && ddev debug download-images >/dev/null
78-
79-
- name: tmate debugging session
80-
uses: mxschmitt/action-tmate@v3
38+
- uses: ddev/github-action-add-on-test@v2
8139
with:
82-
limit-access-to-actor: true
83-
github-token: ${{ secrets.GITHUB_TOKEN }}
84-
if: github.event.inputs.debug_enabled == 'true'
85-
86-
- name: tests
87-
run: bats tests
88-
89-
# keepalive-workflow adds a dummy commit if there's no other action here, keeps
90-
# GitHub from turning off tests after 60 days
91-
- uses: gautamkrishnar/keepalive-workflow@v1
92-
if: matrix.ddev_version == 'stable'
40+
ddev_version: ${{ matrix.ddev_version }}
41+
token: ${{ secrets.GITHUB_TOKEN }}
42+
debug_enabled: ${{ github.event.inputs.debug_enabled }}
43+
addon_repository: ${{ env.GITHUB_REPOSITORY }}
44+
addon_ref: ${{ env.GITHUB_REF }}

README.md

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,10 @@ It contains several components from Grafana stack:
2828
- **[Tempo](https://grafana.com/traces/)**: an open source, easy-to-use, and
2929
high-scale distributed tracing backend.
3030

31-
Be aware that this addon uses a lot of port mapping, so port numbers may overlap
32-
with another running ddev project or local apps, that can lead to startup
33-
errors, and even hidden errors with "503: No ddev back-end site available" if
34-
the same port is configured with HTTP on one project and HTTPS on another, here
35-
is the issue about this: https://github.com/ddev/ddev/issues/4794
36-
37-
To resolve such issues try to find the conflicting port and comment it or change
38-
the port number to a free one.
39-
4031
## Installation
4132

4233
1. In the DDEV project directory:
4334

44-
For DDEV v1.23.5 or above run
45-
46-
```sh
47-
ddev add-on get MurzNN/ddev-grafana
48-
```
49-
50-
For earlier versions of DDEV run
51-
5235
```sh
5336
ddev get MurzNN/ddev-grafana
5437
```
@@ -62,28 +45,12 @@ the port number to a free one.
6245
3. Open the Grafana web interface via the url:
6346
https://your-project-name.ddev.site:3000/
6447

65-
## Customizations
66-
67-
If you need to run several projects with Tempo OpenTelemetry collectors, with
68-
default settings it will fail, because several projects can't use the same port
69-
number on the host network. To fix this you should disable mapping ports to the
70-
host network on the second project via renaming the file
71-
`docker-compose.grafana.host-ports.yaml` to
72-
`docker-compose.grafana.host-ports.yaml.disabled`, or change port numbers to
73-
unique ones, and restart the projects.
74-
75-
76-
If you want to disable binding Grafana services to the localhost, rename the
77-
files:
78-
- `docker-compose.grafana.localhost.yaml` to
79-
`docker-compose.grafana.namedhosts.yaml.disabled`
80-
- `docker-compose.grafana.namedhosts.yaml.disabled` to
81-
`docker-compose.grafana.namedhosts.yaml`
82-
83-
84-
If you need to expose non-HTTP ports (gRPC, etc), you can uncomment them in the
85-
`docker-compose.grafana.localhost.yaml` file.
48+
4. Configure the OpenTelemetry endpoint in your application
49+
to the `http://opentelemetry-grafana:4318`.
8650

51+
By default, the add-on configures the `OTEL_EXPORTER_OTLP_ENDPOINT`
52+
environment variable with this endpoint, you can disable this in the file
53+
`.ddev/config.grafana.logs.yaml`.
8754

8855
** Contributed and maintained by [@MurzNN](https://github.com/MurzNN).
8956

config.grafana.logs.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ webimage_extra_packages:
22
- syslog-ng
33

44
web_extra_daemons:
5-
- name: "syslog-ng"
6-
command: "/usr/bin/sudo /usr/sbin/syslog-ng -F --no-caps"
5+
- name: 'syslog-ng'
6+
command: '/usr/bin/sudo /usr/sbin/syslog-ng -F --no-caps'
77
directory: /var/www/html
8+
9+
web_environment:
10+
- OTEL_EXPORTER_OTLP_ENDPOINT=http://opentelemetry-grafana:4318

docker-compose.grafana.alloy.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
services:
2+
grafana-alloy:
3+
container_name: 'ddev-${DDEV_SITENAME}-grafana-alloy'
4+
image: grafana/alloy:latest
5+
user: '${UID:-}:${GID:-}'
6+
entrypoint:
7+
- /bin/alloy
8+
- run
9+
- --server.http.listen-addr=0.0.0.0:12345
10+
- --storage.path=/var/lib/alloy/data
11+
- --stability.level=experimental
12+
- /etc/alloy/config.alloy
13+
labels:
14+
com.ddev.site-name: ${DDEV_SITENAME}
15+
com.ddev.approot: ${DDEV_APPROOT}
16+
volumes:
17+
- type: bind
18+
source: ./grafana/alloy/config.alloy
19+
target: /etc/alloy/config.alloy
20+
# - grafana-alloy-data:/var/lib/alloy/data
21+
# Configuration to write logs to the file is in a separate file:
22+
# config.grafana.logs.yaml
23+
- web-logs-data:/var/log
24+
networks:
25+
default:
26+
aliases:
27+
- opentelemetry-grafana
28+
29+
environment:
30+
- VIRTUAL_HOST=$DDEV_HOSTNAME
31+
- HTTP_EXPOSE=12345:12345,4317:4317,4318:4318,9411:9411,14268:14268
32+
- HTTPS_EXPOSE=12345:12345,4317:4317,4318:4318,9411:9411,14268:14268
33+
volumes:
34+
# grafana-alloy-data:
35+
# name: 'ddev-${DDEV_SITENAME}_grafana-alloy-data'
36+
web-logs-data:
37+
name: 'ddev-${DDEV_SITENAME}_web-logs'

docker-compose.grafana.logs.yaml renamed to docker-compose.grafana.loki.yaml

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ services:
66
# because supervisord requires write permission for the current user.
77
- web-logs-data:/var/log
88

9-
loki:
9+
grafana-loki:
1010
image: grafana/loki:latest
11-
user: "${UID:-}:${GID:-}"
12-
container_name: "ddev-${DDEV_SITENAME}-loki"
11+
user: '${UID:-}:${GID:-}'
12+
container_name: 'ddev-${DDEV_SITENAME}-grafana-loki'
1313
volumes:
1414
- type: bind
1515
source: ./grafana/loki/loki.yaml
1616
target: /etc/loki/local-config.yaml
17-
- loki-data:/loki
17+
- grafana-loki-data:/data
1818
labels:
1919
com.ddev.site-name: ${DDEV_SITENAME}
2020
com.ddev.approot: ${DDEV_APPROOT}
@@ -23,20 +23,6 @@ services:
2323
- HTTP_EXPOSE=3100:3100
2424
- HTTPS_EXPOSE=3100:3100
2525

26-
agent:
27-
container_name: "ddev-${DDEV_SITENAME}-agent"
28-
image: grafana/agent:latest
29-
user: "${UID:-}:${GID:-}"
30-
volumes:
31-
- type: bind
32-
source: ./grafana/agent/agent.yaml
33-
target: /etc/agent/agent.yaml
34-
- web-logs-data:/var/log
35-
# Additional configuration is in the separate file:
36-
# config.grafana.logs.yaml
37-
3826
volumes:
39-
web-logs-data:
40-
name: "ddev-${DDEV_SITENAME}_web-logs"
41-
loki-data:
42-
name: "ddev-${DDEV_SITENAME}_loki"
27+
grafana-loki-data:
28+
name: 'ddev-${DDEV_SITENAME}_grafana-loki-data'

docker-compose.grafana.metrics.yaml

Lines changed: 0 additions & 29 deletions
This file was deleted.

docker-compose.grafana.mimir.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
services:
2+
grafana-mimir:
3+
container_name: 'ddev-${DDEV_SITENAME}-grafana-mimir'
4+
image: grafana/mimir:latest
5+
user: '${UID:-}:${GID:-}'
6+
entrypoint:
7+
- /bin/mimir
8+
- -config.file=/etc/mimir-config/mimir.yaml
9+
labels:
10+
com.ddev.site-name: ${DDEV_SITENAME}
11+
com.ddev.approot: ${DDEV_APPROOT}
12+
volumes:
13+
- type: bind
14+
source: ./grafana/mimir/mimir.yaml
15+
target: /etc/mimir-config/mimir.yaml
16+
- grafana-mimir-data:/data
17+
18+
environment:
19+
- VIRTUAL_HOST=$DDEV_HOSTNAME
20+
- HTTP_EXPOSE=9009:9009
21+
- HTTPS_EXPOSE=9009:9009
22+
volumes:
23+
grafana-mimir-data:
24+
name: 'ddev-${DDEV_SITENAME}_grafana-mimir-data'
Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
services:
2-
tempo:
3-
container_name: "ddev-${DDEV_SITENAME}-tempo"
2+
grafana-tempo:
3+
container_name: 'ddev-${DDEV_SITENAME}-grafana-tempo'
44
image: grafana/tempo:latest
5-
user: "${UID:-}:${GID:-}"
5+
user: '${UID:-}:${GID:-}'
66
command:
7-
- "-config.file=/etc/tempo.yaml"
7+
- '-config.file=/etc/tempo.yaml'
88
volumes:
99
- type: bind
1010
source: ./grafana/tempo/tempo.yaml
1111
target: /etc/tempo.yaml
12-
- tempo-data:/data
12+
- grafana-tempo-data:/data
1313
labels:
1414
com.ddev.site-name: ${DDEV_SITENAME}
1515
com.ddev.approot: ${DDEV_APPROOT}
1616
environment:
1717
- VIRTUAL_HOST=$DDEV_HOSTNAME
18-
- HTTP_EXPOSE=4318:4318,9411:9411,14268:14268
19-
- HTTPS_EXPOSE=4318:4318,9411:9411,14268:14268
2018

2119
volumes:
22-
tempo-data:
23-
name: "ddev-${DDEV_SITENAME}_tempo"
20+
grafana-tempo-data:
21+
name: 'ddev-${DDEV_SITENAME}_grafana-tempo-data'

grafana/agent/agent.yaml

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)