Skip to content

Commit f76b1e6

Browse files
authored
Expose ports by router (#3)
1 parent 9d01384 commit f76b1e6

21 files changed

+499
-193
lines changed

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ 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+
3140
## Installation
3241

3342
1. In the DDEV project directory launch the command:
@@ -59,7 +68,12 @@ files:
5968
- `docker-compose.grafana.namedhosts.yaml.disabled` to
6069
`docker-compose.grafana.namedhosts.yaml`
6170

62-
**Contributed and maintained by [@MurzNN](https://github.com/MurzNN).
71+
72+
If you need to expose non-HTTP ports (gRPC, etc), you can uncomment them in the
73+
`docker-compose.grafana.localhost.yaml` file.
74+
75+
76+
** Contributed and maintained by [@MurzNN](https://github.com/MurzNN).
6377

6478
## Extra
6579

config.grafana.logs.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
webimage_extra_packages:
2+
- syslog-ng
3+
4+
web_extra_daemons:
5+
- name: "syslog-ng"
6+
command: "/usr/bin/sudo /usr/sbin/syslog-ng -F --no-caps"
7+
directory: /var/www/html

config.grafana.traces.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
web_extra_exposed_ports:
2+
# Tempo OTLP/HTTP port
3+
- name: tempo-otlp
4+
container_port: 4318
5+
http_port: 54318 # HTTP port is not really needed, but it's mandatory.
6+
https_port: 4318
7+
8+
# Tempo Zipkin/HTTP port
9+
- name: tempo-zipkin
10+
container_port: 9411
11+
http_port: 59411 # HTTP port is not really needed, but it's mandatory.
12+
https_port: 9411
13+
14+
# Tempo Jaeger/HTTP port
15+
- name: tempo-jaeger
16+
container_port: 14268
17+
http_port: 64268 # HTTP port is not really needed, but it's mandatory.
18+
https_port: 14268

docker-compose.grafana.host-ports.yaml.disabled

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

docker-compose.grafana.localhost.yaml

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

docker-compose.grafana.logs.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
services:
2+
web:
3+
volumes:
4+
# Permissions of this volume are enforced by the
5+
# web-entrypoint.d/ddev-grafana-fix-log-directory-permissions.sh file
6+
# because supervisord requires write permission for the current user.
7+
- web-logs-data:/var/log
8+
9+
loki:
10+
image: grafana/loki:latest
11+
user: "${UID:-}:${GID:-}"
12+
container_name: "ddev-${DDEV_SITENAME}-loki"
13+
volumes:
14+
- type: bind
15+
source: ./grafana/loki/loki.yaml
16+
target: /etc/loki/local-config.yaml
17+
- loki-data:/loki
18+
19+
agent:
20+
container_name: "ddev-${DDEV_SITENAME}-agent"
21+
image: grafana/agent:latest
22+
user: "${UID:-}:${GID:-}"
23+
volumes:
24+
- type: bind
25+
source: ./grafana/agent/agent.yaml
26+
target: /etc/agent/agent.yaml
27+
- web-logs-data:/var/log
28+
# Additional configuration is in the separate file:
29+
# config.grafana.logs.yaml
30+
31+
volumes:
32+
web-logs-data:
33+
name: "ddev-${DDEV_SITENAME}_web-logs"
34+
loki-data:
35+
name: "ddev-${DDEV_SITENAME}_loki"
36+

docker-compose.grafana.metrics.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
services:
2+
prometheus:
3+
container_name: "ddev-${DDEV_SITENAME}-prometheus"
4+
image: prom/prometheus:latest
5+
user: "${UID:-}:${GID:-}"
6+
command:
7+
- '--config.file=/etc/prometheus/prometheus.yaml'
8+
- '--storage.tsdb.path=/prometheus'
9+
- '--web.console.libraries=/etc/prometheus/console_libraries'
10+
- '--web.console.templates=/etc/prometheus/consoles'
11+
- '--web.enable-lifecycle'
12+
volumes:
13+
- type: bind
14+
source: ./grafana/prometheus/prometheus.yaml
15+
target: /etc/prometheus/prometheus.yaml
16+
- prometheus-data:/prometheus
17+
# Scraping metrics for web services can be configured in the file
18+
# grafana/prometheus/prometheus.yaml
19+
20+
volumes:
21+
prometheus-data:
22+
name: "ddev-${DDEV_SITENAME}_prometheus"

docker-compose.grafana.namedhosts.yaml.disabled

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

docker-compose.grafana.traces.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
services:
2+
web:
3+
# Comment this if you don't need to bind trace ports to localhost.
4+
extra_hosts:
5+
- "tempo:127.0.0.1"
6+
7+
tempo:
8+
container_name: "ddev-${DDEV_SITENAME}-tempo"
9+
image: grafana/tempo:latest
10+
# Comment this if you don't need to bind trace ports to localhost.
11+
network_mode: container:ddev-${DDEV_SITENAME}-web
12+
user: "${UID:-}:${GID:-}"
13+
volumes:
14+
- type: bind
15+
source: ./grafana/tempo/tempo.yaml
16+
target: /etc/tempo.yaml
17+
- tempo-data:/data
18+
command:
19+
- "-config.file=/etc/tempo.yaml"
20+
depends_on:
21+
- web
22+
# exposed ports is configured in a separate file:
23+
# config.grafana.tracing.yaml
24+
25+
# # Another approach to expose HTTP tracing endpoints to the ddev host.
26+
# # Only HTTP endoinds supported via this approach.
27+
# labels:
28+
# com.ddev.site-name: ${DDEV_SITENAME}
29+
# com.ddev.approot: $DDEV_APPROOT
30+
# environment:
31+
# - VIRTUAL_HOST=$DDEV_HOSTNAME
32+
# # We need also to pass DDEV default ports here via adding the substring:
33+
# # ${DDEV_ROUTER_HTTP_PORT}:80,${DDEV_MAILHOG_PORT}
34+
# - HTTP_EXPOSE=${DDEV_ROUTER_HTTP_PORT}:80,${DDEV_MAILHOG_PORT}:8025,4318:4318,9411:9411,14268:14268
35+
36+
grafana:
37+
# Required to connect from Grafana container via named hosts.
38+
# Comment this if you don't need to bind trace ports to localhost.
39+
links:
40+
- "web:tempo"
41+
42+
volumes:
43+
tempo-data:
44+
name: "ddev-${DDEV_SITENAME}_tempo"

docker-compose.grafana.yaml

Lines changed: 14 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,29 @@
1-
version: '3.6'
2-
31
services:
42
grafana:
53
container_name: "ddev-${DDEV_SITENAME}-grafana"
64
image: grafana/grafana:latest
7-
user: "${UID}:${GID}"
5+
user: "${UID:-}:${GID:-}"
86
entrypoint:
97
- /usr/share/grafana/bin/grafana-server
108
- --homepath=/usr/share/grafana
119
- --config=/etc/grafana-config/grafana.ini
1210
labels:
1311
com.ddev.site-name: ${DDEV_SITENAME}
14-
com.ddev.approot: $DDEV_APPROOT
12+
com.ddev.approot: ${DDEV_APPROOT}
1513
volumes:
16-
- ./grafana/grafana/config:/etc/grafana-config
17-
- ./grafana/grafana/datasources:/etc/grafana/provisioning/datasources
18-
- ./grafana/grafana/dashboards-provisioning:/etc/grafana/provisioning/dashboards
19-
- ./grafana/grafana/dashboards:/var/lib/grafana/dashboards
14+
- type: bind
15+
source: ./grafana/grafana/config
16+
target: /etc/grafana-config
17+
- type: bind
18+
source: ./grafana/grafana/datasources
19+
target: /etc/grafana/provisioning/datasources
20+
- type: bind
21+
source: ./grafana/grafana/dashboards-provisioning
22+
target: /etc/grafana/provisioning/dashboards
23+
- type: bind
24+
source: ./grafana/grafana/dashboards
25+
target: /var/lib/grafana/dashboards
2026
environment:
2127
- VIRTUAL_HOST=$DDEV_HOSTNAME
2228
- HTTP_EXPOSE=3001:3000 # Grafana web interface via HTTP.
2329
- HTTPS_EXPOSE=3000:3000 # Grafana web interface with HTTPS.
24-
25-
prometheus:
26-
container_name: "ddev-${DDEV_SITENAME}-prometheus"
27-
image: prom/prometheus:latest
28-
user: "${UID}:${GID}"
29-
command:
30-
- '--config.file=/etc/prometheus/prometheus.yaml'
31-
- '--storage.tsdb.path=/prometheus'
32-
- '--web.console.libraries=/etc/prometheus/console_libraries'
33-
- '--web.console.templates=/etc/prometheus/consoles'
34-
- '--web.enable-lifecycle'
35-
volumes:
36-
- ./grafana/prometheus/prometheus.yaml:/etc/prometheus/prometheus.yaml
37-
- prometheus-data:/prometheus
38-
depends_on:
39-
- web
40-
# exposed ports or network mode will be configured via separate files:
41-
# - docker-compose.grafana.localhost.yaml
42-
# - docker-compose.grafana.namedhosts.yaml
43-
44-
loki:
45-
image: grafana/loki:latest
46-
user: "${UID}:${GID}"
47-
container_name: "ddev-${DDEV_SITENAME}-loki"
48-
volumes:
49-
- ./grafana/loki/loki.yaml:/etc/loki/local-config.yaml
50-
- loki-data:/loki
51-
depends_on:
52-
- web
53-
# exposed ports or network mode will be configured via separate files:
54-
# - docker-compose.grafana.localhost.yaml
55-
# - docker-compose.grafana.namedhosts.yaml
56-
57-
tempo:
58-
container_name: "ddev-${DDEV_SITENAME}-tempo"
59-
image: grafana/tempo:latest
60-
user: "${UID}:${GID}"
61-
volumes:
62-
- ./grafana/tempo/tempo.yaml:/etc/tempo.yaml
63-
- tempo-data:/data
64-
command:
65-
- "-config.file=/etc/tempo.yaml"
66-
depends_on:
67-
- web
68-
# exposed ports or network mode will be configured via separate files:
69-
# - docker-compose.grafana.localhost.yaml
70-
# - docker-compose.grafana.namedhosts.yaml
71-
72-
volumes:
73-
tempo-data:
74-
name: "ddev-${DDEV_SITENAME}_tempo"
75-
prometheus-data:
76-
name: "ddev-${DDEV_SITENAME}_prometheus"
77-
loki-data:
78-
name: "ddev-${DDEV_SITENAME}_loki"
79-

0 commit comments

Comments
 (0)