api
api copied to clipboard
Use Rules API to filter alerts/rules for application tenant
Refactors some of the code introduced in https://github.com/observatorium/api/pull/532 thanks to https://github.com/grafana/loki/pull/9128
Issue: https://issues.redhat.com/browse/LOG-4209
Testing: General set up
# Set up cluster
# Install cluster-logging-operator
# In log-tool-box
# Install bootstrap
kc apply -k manifests/bootstrap
# Install CLF
kc apply -k manifests/cluster-logging/loki-default-audit/
# In obs/api
# Build & Push container
export DOCKER_REPO=$MY_REPO/api
make container
podman push $CONTAINER_IMAGE
# In grafana/loki/operator
# Patch the overlay in operator/config to use your obs/api image $CONTAINER_IMAGE
./hack/deploy-aws-storage-secret.sh $MY_BUCKET
# Deploy loki olm
make olm-deploy ....
oc apply -f hack/lokistack_gateway_ocp.yaml
Feature testing
# Create RecordingRule & AlertingRule for user testuser-0 and testuser-1
# Grant necessary permissions to user
oc adm policy add-cluster-role-to-user monitoring-rules-view testuser-0
oc adm policy add-cluster-role-to-user monitoring-rules-edit testuser-0
# Login as user testuser-0 and get API TOKEN
# Use token to CURL rules API with parameters
# Should work
curl -k -H "Authorization: Bearer $LOKI_BEARER_TOKEN" https://lokistack-dev-openshift-logging.apps.MY_CLUSTER/api/logs/v1/application/loki/api/v1/rules?kubernetes_namespace_name=log-test-0
# Should not return any rules
curl -k -H "Authorization: Bearer $LOKI_BEARER_TOKEN" https://lokistack-dev-openshift-logging.apps.MY_CLUSTER/api/logs/v1/application/loki/api/v1/rules?kubernetes_namespace_name=log-test-1
Labeling with do-not-merge/hold as per required Loki API is not released yet.