Observability: Monitoring, logging, and tracing sample - Go
- A Kubernetes cluster with Knative Serving installed and DNS configured.
- Check if Knative monitoring components are installed:
- If pods aren’t found, install .
- Install Docker.
Setup
Build the application container and publish it to a container registry:
- Move into the sample directory:
cd $GOPATH/src/github.com/knative/docs
- Set your preferred container registry:
export REPO="gcr.io/<YOUR_PROJECT_ID>"
This example shows how to use Google Container Registry (GCR). You will need a Google Cloud Project and to enable the Google Container Registry API.
- Use Docker to build your application container:
docker build \
--tag "${REPO}/docs/serving/samples/telemetry-go" \
--file=docs/serving/samples/telemetry-go/Dockerfile .
- Push your container to a container registry:
Replace the image reference path with our published image path in the configuration file (
docs/serving/samples/telemetry-go/sample.yaml
):Manually replace:
image: github.com/knative/docs/docs/serving/samples/telemetry-go
withUse run this command:
Deploy the Service
Deploy this application to Knative Serving:
kubectl apply --filename docs/serving/samples/telemetry-go/
Inspect the created resources with the kubectl
commands:
- View the created Route resource:
kubectl get route --output yaml
- View the created Configuration resource:
kubectl get configurations --output yaml
- View the Revision that was created by the Configuration:
Access the Service
To access this service via curl
, you need to determine its ingress address.
- To determine if your route is ready:
kubectl get route
- Make a request to the service to see the
Hello World!
message:
curl http://telemetrysample-route.default.example.com
- Make a request to the
/log
endpoint to generate logs to thestdout
file and generate files under/var/log
in bothJSON
and plain text formats:
curl http://telemetrysample-route.default.example.com/log
Access Logs
You can access to the logs from Kibana UI - see Logs for more information.
You can access to per request traces from Zipkin UI - see for more information.
Accessing Custom Metrics
You can see published metrics using Prometheus UI. To access to the UI, forward the Prometheus server to your machine:
Then browse to .