Skip to content

Commit

Permalink
feat(infra): add grafana agent code (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssupecial authored Jul 23, 2024
1 parent 0b8d76a commit 2d0a363
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
36 changes: 36 additions & 0 deletions grafana_agent/config/config.river
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
logging {
level = "info"
format = "logfmt"
}

otelcol.receiver.otlp "default" {
http {
endpoint = "0.0.0.0:4318"
metrics_url_path = "/v1/metrics"
}

output {
metrics = [otelcol.exporter.prometheus.metric.input]
traces = [otelcol.exporter.otlphttp.trace.input]
}
}

otelcol.exporter.prometheus "metric" {
forward_to = [prometheus.remote_write.metric.receiver]
}

otelcol.exporter.otlphttp "trace" {
client {
endpoint = "https://grafana.codedang.com/tempo"
tls {
insecure = true
insecure_skip_verify = true
}
}
}

prometheus.remote_write "metric" {
endpoint {
url = "https://grafana.codedang.com/prometheus/api/v1/write"
}
}
51 changes: 51 additions & 0 deletions grafana_agent/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
version: '3'

services:
# prometheus:
# image: prom/prometheus
# container_name: prometheus
# volumes:
# - ./config/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
# command:
# - '--config.file=/etc/prometheus/prometheus.yml'
# - '--storage.tsdb.path=/prometheus'
# - --web.enable-remote-write-receiver
# ports:
# - 9090:9090

agent:
image: grafana/agent:latest
container_name: agent
environment:
- AGENT_MODE=flow
- HOSTNAME=agent
volumes:
- ./config/config.river:/etc/agent/config.river
ports:
- 12345:12345
- 4318:4318 # OTLP over HTTP receiver
command: run --server.http.listen-addr=0.0.0.0:12345 /etc/agent/config.river


# otel-collector:
# image: otel/opentelemetry-collector-contrib:0.67.0
# container_name: otel-collector
# command: [ "--config=/etc/otelcol/otelcol-config.yml" ]
# volumes:
# - ./config/otelcol/otelcol-config.yml:/etc/otelcol/otelcol-config.yml
# ports:
# - "4317:4317" # OTLP over gRPC receiver
# - "4318:4318" # OTLP over HTTP receiver
# - "8888:8888" # Prometheus metrics exposed by the collector
# - "8889:8889" # Prometheus exporter metrics



# grafana:
# image: grafana/grafana
# container_name: grafana
# ports:
# - 3000:3000



0 comments on commit 2d0a363

Please sign in to comment.