Loki
- Canonical Observability
Channel | Revision | Published | Runs on |
---|---|---|---|
latest/stable | 160 | 10 Sep 2024 | |
latest/candidate | 161 | 19 Nov 2024 | |
latest/beta | 177 | 19 Nov 2024 | |
latest/edge | 177 | 16 Nov 2024 | |
1.0/stable | 104 | 12 Dec 2023 | |
1.0/candidate | 104 | 22 Nov 2023 | |
1.0/beta | 104 | 22 Nov 2023 | |
1.0/edge | 104 | 22 Nov 2023 |
juju deploy loki-k8s --channel edge
Deploy Kubernetes operators easily with Juju, the Universal Operator Lifecycle Manager. Need a Kubernetes cluster? Install MicroK8s to create a full CNCF-certified Kubernetes system in under 60 seconds.
Platform:
Loki HTTP API
Charmed Loki exposes its HTTP API over port 3100.
Example 1 - Get Loki version:
/loki/api/v1/status/buildinfo
exposes the build information in a JSON object.
The fields are version
, revision
, branch
, buildDate
, buildUser
, and goVersion
.
$ loki_ip=$(juju status loki-k8s/0 | grep "loki-k8s/0" | awk '{print $4}')
$ curl http://$loki_ip:3100/loki/api/v1/status/buildinfo | jq
{
"version": "2.4.1",
"revision": "f61a4d261",
"branch": "HEAD",
"buildUser": "root@39a6e600b2df",
"buildDate": "2021-11-08T13:09:51Z",
"goVersion": ""
}
Example 2 - Send log lines to Loki with curl:
/loki/api/v1/push
is the endpoint used to send log entries to Loki. The default behavior is for the POST body to be a snappy-compressed protobuf message.
Alternatively, if the Content-Type
header is set to application/json
, a JSON post body can be sent in the following format:
loki_ip=$(juju status loki-k8s/0 | grep "loki-k8s/0" | awk '{print $4}')
curl -v \
-H "Content-Type: application/json" \
-XPOST -s "http://$loki_ip:3100/loki/api/v1/push" \
--data-raw '{"streams": [{ "stream": { "foo": "bar2" }, "values": [ [ "1570818238000000000", "fizzbuzz" ] ] }]}'
Example 3 - Send logs entries to Loki with Promtail:
Promtail is an agent which ships the contents of local logs to Loki. It is usually deployed to every machine that has applications needed to be monitored.
It primarily:
- Discovers targets
- Attaches labels to log streams
- Pushes them to the Loki instance.
Currently, Promtail can tail logs from two sources: local log files and the systemd journal (on AMD64 machines only).
To set up a Promtail instance to work with Loki Charmed Operator please refer to Configuring Promtail documentation. Anyway the most important part is the clients
section in Promtail config file, for instance:
clients:
- url: http://<LOKI_ADDRESS>:3100/loki/api/v1/push