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

SWATCH-2297: Rename metric for ingested usage data from Prometheus #3961

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Sgitario
Copy link
Contributor

Jira issue: SWATCH-2297
Relates to #3888

Description

These changes include:

  • Rename metric from "rhsm-subscriptions.swatch_metrics_ingested_usage_total" to "swatch_metrics_ingested_usage_total"
  • Rename tag from "product_tag" to "product"
  • Use Counter.Builder for better readibility.

This is to follow the same convention as written in the document attached in the JIRA ticket epic.

Testing

Setup

  1. Start the needed services
    RHSM_SUBSCRIPTIONS_ENABLE_SYNCHRONOUS_OPERATIONS=true DEV_MODE=true PROM_URL=http://localhost:8082/api/metrics/v1/telemeter/api/v1 SWATCH_CONTRACTS_INTERNAL_SERVICE=http://localhost:8003 SERVER_PORT=8000 SPRING_PROFILES_ACTIVE=worker,kafka-queue,api,capacity-ingress,kafka-queue,rhsm-conduit ./gradlew :bootRun

Steps

  1. Input event messages to the Kafka queue. Remember to increment the hour for each submission.
    { "sla": "Premium", "org_id": "111111111", "timestamp": "2024-10-24T15:00:00.0000+04:00", "conversion": false, "event_type": "snapshot_rhel-for-x86-els-payg-addon_vCPUs", "expiration": "2025-06-10T11:00:00.0000+04:00", "instance_id": "d147ddf2-be4a-4a59-acf7-7f222758b47d", "product_tag": [ "rhel-for-x86-els-payg-addon" ], "display_name": "automation__cluster_d147ddf2-be4a-4a59-acf7-7f222758b47c", "event_source": "prometheus", "billing_provider": "aws", "measurements": [ { "value": 4.0, "metric_id": "vCPUs" } ], "service_type": "RHEL System" }
  2. Call the metrics endpoint.
    http ':9000/metrics' | grep 'swatch_metrics'

Verification

  1. Confirm the counter's sum based on the number of submissions.
    swatch_metrics_ingested_usage_total{billing_provider="aws",metric_id="vCPUs",product="rhel-for-x86-els-payg-addon"} 8.0

These changes include:
- Rename metric from "rhsm-subscriptions.swatch_metrics_ingested_usage_total" to "swatch_metrics_ingested_usage_total"
- Rename tag from "product_tag" to "product"
- Use Counter.Builder for better readibility. 

This is to follow the same convention as written in the document attached in the JIRA ticket epic.
@Sgitario Sgitario added QE Pull request should be approved by QE before merge Dev Pull requests that need developer review labels Nov 19, 2024
@Sgitario
Copy link
Contributor Author

@Aurobinda55 @wottop this is related to #3888, so would you mind taking a look here too?
fyi @awood

@Aurobinda55
Copy link

Aurobinda55 commented Nov 19, 2024

Added two messages with values 4.0 and 2.0 to platform.rhsm-subscriptions.service-instance-ingress and got a log message in the tally service pod that indicates the counter's sum based on the number of submissions in the tally. Also, checked rhsm_subscriptions_swatch_metrics_ingested_usage_total changed as swatch_metrics_ingested_usage_total and product_tag as product

message1={"sla": "Premium",   "org_id": "3340851",   "timestamp": "2024-11-19T01:00:00.0000+04:00",   "conversion": 'false',   "event_type": "snapshot_rhel-for-x86-els-payg-addon_vCPUs",   "expiration": "2025-06-10T11:00:00.0000+04:00", "instance_id": "d147ddf2-be4a-4a59-acf7-7f222758b47e",   "product_tag": [ "rhel-for-x86-els-payg-addon"   ],   "display_name": "automation__cluster_d147ddf2-be4a-4a59-acf7-7f222758b479",   "event_source": "prometheus","billing_provider": "aws",   "measurements": [ { "value": 4.0, "metric_id": "vCPUs" }   ],"service_type": "RHEL System" }

message2={"sla": "Premium",   "org_id": "3340851",   "timestamp": "2024-11-19T05:00:00.0000+04:00",   "conversion": 'false',   "event_type": "snapshot_rhel-for-x86-els-payg-addon_vCPUs",   "expiration": "2025-06-10T11:00:00.0000+04:00", "instance_id": "d147ddf2-be4a-4a59-acf7-7f222758b47k",   "product_tag": [ "rhel-for-x86-els-payg-addon"   ],   "display_name": "automation__cluster_d147ddf2-be4a-4a59-acf7-7f222758b477",   "event_source": "prometheus","billing_provider": "aws",   "measurements": [ { "value": 2.0, "metric_id": "vCPUs" }   ],"service_type": "RHEL System" }

sh-5.1$ curl http://localhost:9000/metrics|  grep 'rhsm_subscriptions_swatch_metrics_ingested_usage_total'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 38720  100 38720    0     0  1021k      0 --:--:-- --:--:-- --:--:-- 1021k

******************************************

sh-5.1$ curl http://localhost:9000/metrics|  grep 'swatch_metrics_ingested_usage_total'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 38675  100 38675    0     0  2098k      0 --:--:-- --:--:-- --:--:-- 2098k
# HELP swatch_metrics_ingested_usage_total  
# TYPE swatch_metrics_ingested_usage_total counter
**swatch_metrics_ingested_usage_total**{billing_provider="aws",metric_id="vCPUs",**product**="rhel-for-x86-els-payg-addon"} 6.0
sh-5.1$ 

@kahowell kahowell self-assigned this Nov 19, 2024
@kahowell kahowell added Dev/approved Pull requests that have been approved by all assigned developers and removed Dev Pull requests that need developer review labels Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dev/approved Pull requests that have been approved by all assigned developers QE Pull request should be approved by QE before merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants