Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Rules API to filter alerts/rules for application tenant #578

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

JoaoBraveCoding
Copy link
Contributor

@JoaoBraveCoding JoaoBraveCoding commented Sep 27, 2023

Refactors some of the code introduced in #532 thanks to grafana/loki#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

@JoaoBraveCoding JoaoBraveCoding changed the title Use Rules API to filter alerts/rules per namespace for application tenant Use Rules API to filter alerts/rules for application tenant Oct 2, 2023
@JoaoBraveCoding JoaoBraveCoding marked this pull request as ready for review October 2, 2023 16:48
@periklis periklis added the do-not-merge/hold Hold don't merge this yet. label Oct 4, 2023
@periklis
Copy link
Contributor

periklis commented Oct 4, 2023

Labeling with do-not-merge/hold as per required Loki API is not released yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/hold Hold don't merge this yet.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants