This page provides a quick walk-through for setting up the Loki Operator with NetObserv. You can find here more documentation (or there for OpenShift).
The Loki Operator integrates a gateway that implements multi-tenancy & authentication with Loki for logging.
NetObserv requires to use a specific tenant for Loki, named network, which uses a specific tenant mode implemented in Loki Operator 5.6+. For that reason, NetObserv is not compatible with prior version of the Loki Operator.
Install the Loki operator using Operator Hub. If using OpenShift, open the Console and navigate to Administrator view -> Operators -> OperatorHub.
Search for loki. You should find Loki Operator in Red Hat catalog.
Install the operator with the default configuration.
We provide a hack script that uses AWS S3 storage, to run the steps described below. It assumes you have the AWS CLI installed with credentials configured. It will create a S3 bucket and configure Loki with it.
The first argument is the bucket name, second is the AWS region. Example:
./hack/loki-operator.sh netobserv-loki eu-west-1If you choose to run it, you can ignore the following steps.
For simplicity, this guide assumes Loki is deployed in the same namespace as NetObserv.
If it doesn't already exist, create the netobserv namespace:
kubectl create ns netobservLoki operator requires an external storage, such as Amazon S3. Check the documentation to set it up. Make sure you create the secret in netobserv namespace. Take note of the storage configuration you need to set in LokiStack, as mentioned in the linked documentation.
Example with AWS S3, using aws CLI:
S3_NAME="netobserv-loki"
AWS_REGION="eu-west-1"
AWS_KEY=$(aws configure get aws_access_key_id)
AWS_SECRET=$(aws configure get aws_secret_access_key)
aws s3api create-bucket --bucket $S3_NAME --region $AWS_REGION --create-bucket-configuration LocationConstraint=$AWS_REGION
kubectl create -n netobserv secret generic lokistack-dev-s3 \
--from-literal=bucketnames="$S3_NAME" \
--from-literal=endpoint="https://s3.${AWS_REGION}.amazonaws.com" \
--from-literal=access_key_id="${AWS_KEY}" \
--from-literal=access_key_secret="${AWS_SECRET}" \
--from-literal=region="${AWS_REGION}"Then create a LokiStack in netobserv namespace. When using OpenShift, navigate to:
Administrator view -> Operators -> Installed Operators -> Loki Operator -> LokiStack -> Create LokiStack
- Name it
loki(any name is fine, but you need to adapt the URLs below accordingly) - Choose the size. While not suitable for production,
1x.demois OK for testing / demo (or1x.extra-smallin operator 5.7). Note that very small clusters (e.g. 3 worker nodes) require1x.demo, see troubleshooting section below. - Set
Object Storage->Secretas noted above. - Set
Tenants Configuration->Modetoopenshift-network.
This will create gateway, distributor, compactor, ingester, querier and query-frontend components.
Once the Loki stack is up and running, you need to configure NetObserv to communicate to Loki through its gateway service:
loki:
mode: LokiStack
lokiStack:
name: lokiYou then need to define ClusterRoleBindings for allowed users or groups, such as this one for a user named test. This can also be done from the CLI:
oc adm policy add-cluster-role-to-user netobserv-loki-reader testCluster admins do not need this role binding.
-
Logs are by default
--log.level=warn. You can set--log.level=debugingateway.goandopa_openshift.goto get more logs. -
AWS region not set for deploy-example-secret.sh If
aws configure get regionreturns blank, the shell will fail. You can force region usingaws configure --region us-east-1for example. -
Insufficient CPU or memory If your pods hang in
Pendingstate, you should double check their status usingoc describeWe recommand to use size: 1x.extra-small but this still requires a lot of resources. You can decrease them in internal/manifests/internal/sizes.go and set100mfor each CPUs and256Mifor each Memories -
Certificate errors in Gateway logs Check ZeroSSL.com CA with acme.sh
-
Running custom Loki query bypassing the gateway:
oc exec -it netobserv-plugin-d894b4544-97tq2 -- curl --cert /var/loki-status-certs-user/tls.crt --key /var/loki-status-certs-user/tls.key --cacert /var/loki-status-certs-ca/service-ca.crt -k -H "X-Scope-OrgID: network" https://loki-query-frontend-http:3100/loki/api/v1/label/DstK8S_Namespace/values