istio.io/istio@v0.0.0-20240520182934-d79c90f27776/samples/open-telemetry/loki/REAME.md (about) 1 # Open Telemetry with Loki 2 3 This sample demonstrates Istio's Open Telemetry [ALS(Access Log Service)](https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/access_loggers/grpc/v3/als.proto) and sending logs to [Loki](https://github.com/grafana/loki). 4 5 ## Install Istio 6 7 Run the following script to install Istio with an Open Telemetry ALS provider: 8 9 ```bash 10 istioctl install -f iop.yaml -y 11 ``` 12 13 ## Setup Loki 14 15 Run the following script to install `Loki`: 16 17 ```bash 18 kubectl apply -f ../../addons/loki.yaml -n istio-system 19 ``` 20 21 ## Setup otel-collector service 22 23 First, create an `otel-collector` backend with a simple configuration. 24 25 ```bash 26 kubectl apply -f otel.yaml -n istio-system 27 ``` 28 29 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](https://github.com/open-telemetry/opentelemetry-collector-contrib). 30 31 ```yaml 32 receivers: 33 otlp: 34 protocols: 35 grpc: 36 http: 37 processors: 38 batch: 39 attributes: 40 actions: 41 - action: insert 42 key: loki.attribute.labels 43 value: podName, namespace,cluster,meshID 44 exporters: 45 loki: 46 endpoint: "http://loki.istio-system.svc:3100/loki/api/v1/push" 47 logging: 48 loglevel: debug 49 extensions: 50 health_check: 51 service: 52 extensions: 53 - health_check 54 pipelines: 55 logs: 56 receivers: [otlp] 57 processors: [attributes] 58 exporters: [loki, logging] 59 ``` 60 61 ## Apply Telemetry API 62 63 Next, add a Telemetry resource that tells Istio to send access logs to the OpenTelemetry collector. 64 65 ```bash 66 kubectl apply -f telemetry.yaml 67 ``` 68 69 ## Check ALS output 70 71 Following this [doc](../../httpbin/README.md), start the `fortio` and `httpbin` services. 72 73 Run the following script to request `httpbin` from `fortio`. 74 75 ```bash 76 kubectl exec -it deploy/fortio -- fortio curl httpbin:8000/ip 77 ``` 78 79 Run the following script to view ALS output. 80 81 ```bash 82 kubectl logs -l app=opentelemetry-collector -n istio-system --tail=-1 83 ``` 84 85 You can also check the Grafana logs: 86 87 ```bash 88 istioctl dashboard grafana 89 ``` 90 91 Learn how to use Loki with Grafana [here](https://grafana.com/docs/grafana/v8.4/datasources/loki/). 92 93 ## Cleanup 94 95 ```bash 96 kubectl delete -f otel.yaml -n istio-system 97 kubectl delete telemetry mesh-logging -n istio-system 98 istioctl uninstall --purge -y 99 ```