mzcompose.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. from materialize import MZ_ROOT
  10. from materialize.mzcompose.composition import Composition, Service
  11. SERVICES = [
  12. Service(
  13. "prometheus",
  14. {
  15. "image": "prom/prometheus:v2.46.0",
  16. "ports": ["9090:9090"],
  17. "volumes": [
  18. "./prometheus.yml:/etc/prometheus/prometheus.yml",
  19. "../../mzdata/prometheus:/mnt/services",
  20. ],
  21. "command": [
  22. "--config.file=/etc/prometheus/prometheus.yml",
  23. "--web.enable-remote-write-receiver",
  24. ],
  25. "extra_hosts": ["host.docker.internal:host-gateway"],
  26. "allow_host_ports": True,
  27. },
  28. ),
  29. Service(
  30. "tempo",
  31. {
  32. "image": "grafana/tempo:2.2.0",
  33. "ports": ["4317:4317", "3200:3200"],
  34. "volumes": [
  35. "./tempo.yml:/etc/tempo.yml",
  36. "../../mzdata/tempo:/tmp/tempo",
  37. ],
  38. "command": ["-config.file=/etc/tempo.yml"],
  39. "allow_host_ports": True,
  40. },
  41. ),
  42. Service(
  43. "grafana",
  44. {
  45. "image": "grafana/grafana:10.0.3",
  46. "ports": ["3000:3000"],
  47. "environment": [
  48. "GF_AUTH_ANONYMOUS_ENABLED=true",
  49. "GF_AUTH_ANONYMOUS_ORG_ROLE=Admin",
  50. ],
  51. "volumes": [
  52. "./grafana/datasources:/etc/grafana/provisioning/datasources",
  53. ],
  54. "allow_host_ports": True,
  55. },
  56. ),
  57. ]
  58. def workflow_default(c: Composition) -> None:
  59. # Create the `mzdata/prometheus|tempo` directories that will be bind mounted into
  60. # the containers before invoking Docker Compose, since otherwise the Docker daemon
  61. # will create the directory as root, and `environmentd` won't be able to write to them.
  62. (MZ_ROOT / "mzdata" / "prometheus").mkdir(parents=True, exist_ok=True)
  63. (MZ_ROOT / "mzdata" / "tempo").mkdir(parents=True, exist_ok=True)
  64. c.up()
  65. print(f"Prometheus running at http://localhost:{c.default_port('prometheus')}")
  66. print(f"Tempo running at http://localhost:{c.default_port('tempo')}")
  67. print(f"Grafana running at http://localhost:{c.default_port('grafana')}")