2.5 KiB
Open Telemetry with Loki
This sample demonstrates Istio's Open Telemetry ALS(Access Log Service) and sending logs to Loki.
Install Istio
Run the following script to install Istio with an Open Telemetry ALS provider:
istioctl install -f iop.yaml -y
Setup Loki
Run the following script to install Loki:
kubectl apply -f ../../addons/loki.yaml -n istio-system
Setup otel-collector service
First, create an otel-collector backend with a simple configuration.
kubectl apply -f otel.yaml -n istio-system
With the following configuration, otel-collector-contrib will create a grpc receiver on port 4317, and output to stdout. You can find more details here.
receivers:
otlp:
protocols:
grpc:
http:
processors:
batch:
attributes:
actions:
- action: insert
key: loki.attribute.labels
value: podName, namespace,cluster,meshID
exporters:
loki:
endpoint: "http://loki.istio-system.svc:3100/loki/api/v1/push"
logging:
loglevel: debug
extensions:
health_check:
service:
extensions:
- health_check
pipelines:
logs:
receivers: [otlp]
processors: [attributes]
exporters: [loki, logging]
Apply Telemetry API
Next, add a Telemetry resource that tells Istio to send access logs to the OpenTelemetry collector.
kubectl apply -f telemetry.yaml
Check ALS output
Following this doc, start the fortio and httpbin services.
Run the following script to request httpbin from fortio.
kubectl exec -it deploy/fortio -- fortio curl httpbin:8000/ip
Run the following script to view ALS output.
kubectl logs -l app=opentelemetry-collector -n istio-system --tail=-1
You can also check the Grafana logs:
istioctl dashboard grafana
Learn how to use Loki with Grafana here.
Cleanup
kubectl delete -f otel.yaml -n istio-system
kubectl delete telemetry mesh-logging -n istio-system
istioctl uninstall --purge -y