Integrate Loki
Nullplatform supports Loki as a logs provider. This guide explains how to leverage Loki's capabilities while working with Nullplatform.
Loki Logs
When you set Loki as your logging provider, Nullplatform will configure the underlying logging infrastructure of your instances to directly send logs to Loki.
Currently, the Loki logs integration is available for container-based scopes only (not serverless).
Configuration for Kubernetes
To configure Loki in your Kubernetes environment, follow these steps:
1. Update null-metrics
In the null-metrics configuration, update the env
section of the nullplatform-log-controller
container as follows:
env:
- name: LOKI_LOGS_ENABLED
value: 'true'
- name: LOKI_HOST
value: 'your-loki-host'
- name: LOKI_PORT
value: 'your-loki-port'
- name: LOKI_MATCH_REGEX
value: 'your-match-regex' # Optional, defaults to "container.*.application"
# Choose either username/password OR bearer token for authentication
- name: LOKI_USER
valueFrom:
secretKeyRef:
name: loki-secret
key: LOKI_USER
- name: LOKI_PASSWORD
valueFrom:
secretKeyRef:
name: loki-secret
key: LOKI_PASSWORD
# OR
- name: LOKI_BEARER_TOKEN
valueFrom:
secretKeyRef:
name: loki-secret
key: LOKI_BEARER_TOKEN
2. Create Kubernetes Secret
Before applying the null-metrics
configuration, create a Kubernetes secret named loki-secret
containing your Loki credentials. Use one of the following templates based on your authentication method:
For username/password authentication:
apiVersion: v1
kind: Secret
metadata:
name: loki-secret
namespace: nullplatform-tools
type: Opaque
data:
LOKI_USER: <base64-encoded-username>
LOKI_PASSWORD: <base64-encoded-password>
For bearer token authentication:
apiVersion: v1
kind: Secret
metadata:
name: loki-secret
namespace: nullplatform-tools
type: Opaque
data:
LOKI_BEARER_TOKEN: <base64-encoded-token>
Kubernetes Agent Variables
The following variables can be configured in the Kubernetes agent:
LOKI_LOGS_ENABLED
: Set to "true" to enable Loki logging.LOKI_HOST
: The hostname of your Loki server.LOKI_PORT
: The port number for your Loki server.LOKI_MATCH_REGEX
: (Optional) A regex pattern to match log streams. Defaults to "container.*.application" if not set.LOKI_USER
: (Optional) Username for Loki authentication.LOKI_PASSWORD
: (Optional) Password for Loki authentication.LOKI_BEARER_TOKEN
: (Optional) Bearer token for Loki authentication.
Remember to use either the username/password combination or the bearer token for authentication, not both.
Granting Loki Access to Nullplatform
To give Loki access to Nullplatform, create the following nrn
keys:
{
"loki.host": "<loki-host>",
"loki.port": "<loki-port>",
"loki.logKey": "<log-key>" //Optional, defaults is all log
}
Then, depending on your authentication method, add either:
For username/password authentication:
{
"loki.username": "<loki-username>",
"loki.password": "<loki-password>"
}
OR
For token authentication:
{
"loki.token": "<loki-token>"
}
To configure Loki as the log provider, in any branch of nrn, specify:
{
"global.logProvider": "loki"
}