-
Notifications
You must be signed in to change notification settings - Fork 43
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
SWATCH-1629: Include addonSamples as a template for accountQueryTemplate #2485
Conversation
Looks like you run without selinux enforcing? PSA: https://stopdisablingselinux.com/ Edit: If no, I'm curious how this works otherwise without |
Test Step corrections/notes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The steps listed don't actually have the application exercising the new template you added. The results you got are misleading. The openshift-metering-worker
profile actually uses the set of templates found in application-openshift-metering-worker.yaml. Coincidentally, the templates are identical so you got false positive results.
You can verify that the template isn't being used by setting the OPENSHIFT_ENABLED_ACCOUNT_PROMQL
environment variable during startup. When you make the http request, you can see that URL wiremock is receiving didn't change to "bananas".
OPENSHIFT_ENABLED_ACCOUNT_PROMQL="bananas" PROM_URL="http://localhost:8101/api/v1/" SUBSCRIPTION_USE_STUB=true USER_USE_STUB=true RHSM_RBAC_USE_STUB=true SUBSCRIPTION_SYNC_ENABLED=true ENABLE_SYNCHRONOUS_OPERATIONS=true SPRING_PROFILES_ACTIVE=openshift-metering-worker,api,kafka-queue ./gradlew :bootRun
The hourly metering job is what exercises the query template defined in application.yaml. You can do this by starting the application with the following profiles.
SPRING_PROFILES_ACTIVE=metering-job,kafka-queue
You can also set OPENSHIFT_ENABLED_ACCOUNT_PROMQL
as noted above to see the difference.
TODO
- Update QueryBuilder to select which query template to use based on swatch-product-configuration.
var templateKey = queryDescriptor.getMetric().getPrometheus().getQueryKey()
should do the trick.
- Ensure all the product configurations that have a
prometheus
block also have "queryKey" set. Alternatively, you could set the string to "default" in thecom.redhat.swatch.configuration.registry.PrometheusMetric
class
This is odd since I didn't need this step. |
I had to disable for some reason I don't remember now :) |
b12cc9e
to
65da40e
Compare
65da40e
to
9a5a567
Compare
PR updated with the requested changes and description updated as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jira issue: SWATCH-1629
Description
Currently, Rhods contains "addonSamples", but application.yaml does not have a template for it. Therefore, it reads everything by "default" using default query and filters it later in the code.
Now, we have properly configured the "addonSamples" query profile that includes the resource_type and resource_name filters directly in the prometheus query.
Testing
I've verified these changes via:
a. Using the new prometheus promql script:
1.- Run the script:
2.- It will generate the following output:
Checking the
Accounts
link, you can confirm that the query is now:group(min_over_time(ocm_subscription_resource{resource_type="addon", resource_name='addon-open-data-hub', external_organization != '', billing_model='marketplace'}[1h])) by (external_organization)
Before these changes, the filters were
group(min_over_time(ocm_subscription_resource{product='rhods', external_organization != '', billing_model='marketplace'}[1h])) by (external_organization)
.b. Using the service
1.- podman-compose up
2.- Mock the prometheus server at localhost:
Create the stub directory:
mkdir -p stub/__files
Add a stub file to return no data:
stub/__files/empty.json
Run wiremock:
podman run -it --rm -p 8101:8080 --name wiremock -v $PWD/stub:/home/wiremock:z wiremock/wiremock:2.32.0 --verbose
Configure stubbing for prometheus:
curl -X POST --data '{ "priority": 5, "request": { "urlPath": "/api/v1/query_range", "method": "GET" }, "response": { "status": 200, "bodyFileName": "empty.json", "headers":{"Content-Type":"application/json"} }}' http://localhost:8101/__admin/mappings/new
3.- Start the swatch metrics app:
PROM_URL="http://localhost:8101/api/v1/" SPRING_PROFILES_ACTIVE=metering-job,kafka-queue ./gradlew :bootRun
And wait until the app terminates.
5.- Check the prometheus logs (you started the wiremock server using --verbose) and confirm you received:
Which now it contains the
resource_name=addon-open-data-hub
andresource_type=addon
.Before these changes, the query was: