-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
113 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Sending logs to Grafana Loki | ||
|
||
```mermaid | ||
graph LR; | ||
pino["Pino Opentelemetry Transport"] | ||
otel["OTEL Collector"] | ||
loki["Loki"] | ||
grafana["Grafana"] | ||
pino-->otel; | ||
otel-->loki; | ||
loki-->grafana; | ||
``` | ||
|
||
## Running the example | ||
|
||
### Local infrastructure | ||
|
||
Run the required infra locally with | ||
`docker compose up` | ||
|
||
It will boot [Grafana](https://grafana.com/docs/grafana/latest/), [Loki](https://grafana.com/docs/loki/latest/) and an [Opentelemetry Collector](https://opentelemetry.io/docs/collector/). | ||
|
||
Loki ingester readiness can be checked at | ||
[http://localhost:3100/ready](http://localhost:3100/ready). | ||
|
||
The logs can be inspected in Grafana UI at | ||
[http://localhost:3000/explore](http://localhost:3000/explore). | ||
|
||
[This article](https://grafana.com/docs/opentelemetry/visualization/loki-data/) explains how to inspect OTLP data in the Grafana UI. | ||
|
||
### Generating logs | ||
Run the [trace-context](../trace-context) example, but skip the `docker compose up` part | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
version: "3" | ||
|
||
networks: | ||
loki: | ||
|
||
services: | ||
loki: | ||
image: grafana/loki:2.9.0 | ||
ports: | ||
- "3100:3100" | ||
command: -config.file=/etc/loki/local-config.yaml | ||
networks: | ||
- loki | ||
|
||
grafana: | ||
environment: | ||
- GF_PATHS_PROVISIONING=/etc/grafana/provisioning | ||
- GF_AUTH_ANONYMOUS_ENABLED=true | ||
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin | ||
entrypoint: | ||
- sh | ||
- -euc | ||
- | | ||
mkdir -p /etc/grafana/provisioning/datasources | ||
cat <<EOF > /etc/grafana/provisioning/datasources/ds.yaml | ||
apiVersion: 1 | ||
datasources: | ||
- name: Loki | ||
type: loki | ||
access: proxy | ||
orgId: 1 | ||
url: http://loki:3100 | ||
basicAuth: false | ||
isDefault: true | ||
version: 1 | ||
editable: false | ||
EOF | ||
/run.sh | ||
image: grafana/grafana:latest | ||
ports: | ||
- "3000:3000" | ||
networks: | ||
- loki | ||
depends_on: | ||
- loki | ||
|
||
otel-collector: | ||
image: otel/opentelemetry-collector-contrib:latest | ||
command: ["--config=/etc/otel-collector-config.yaml"] | ||
volumes: | ||
- ./otel-collector-config.yaml:/etc/otel-collector-config.yaml | ||
- /tmp/test-logs:/etc/test-logs | ||
ports: | ||
- "4317:4317" # OTLP gRPC receiver | ||
networks: | ||
- loki | ||
depends_on: | ||
- loki |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
receivers: | ||
otlp: | ||
protocols: | ||
grpc: | ||
|
||
exporters: | ||
loki: | ||
endpoint: http://loki:3100/loki/api/v1/push | ||
|
||
processors: | ||
batch: | ||
|
||
service: | ||
pipelines: | ||
logs: | ||
receivers: [otlp] | ||
processors: [] | ||
exporters: [loki] | ||
|