Skip to content

Commit

Permalink
#4: component entities moved from metric name into label set
Browse files Browse the repository at this point in the history
  • Loading branch information
bissquit committed Apr 22, 2022
1 parent 32eec8f commit e38ad28
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,20 @@ You may pass options both via command line arguments or environment variables:
Metrics example:

```text
gradle_ingest_queue_pending{url="http://localhost:8081"} 0
gradle_ingest_queue_requested{url="http://localhost:8081"} 0
gradle_ingest_queue_ageMins{url="http://localhost:8081"} 0
gradle_ingest_queue_requestWaitTimeSecs{url="http://localhost:8081"} 0
gradle_ingest_queue_incomingRate1m{url="http://localhost:8081"} 0.03221981766544038
gradle_ingest_queue_incomingRate5m{url="http://localhost:8081"} 0.02219163413405735
gradle_ingest_queue_incomingRate15m{url="http://localhost:8081"} 0.021373141599789678
gradle_ingest_queue_processingRate1m{url="http://localhost:8081"} 0.03399783025186821
gradle_ingest_queue_processingRate5m{url="http://localhost:8081"} 0.022374841163558885
gradle_ingest_queue_processingRate15m{url="http://localhost:8081"} 0.021459615070953553
gradle_ingest_queue{entity="pending",url="http://localhost:8081/info/ingest-queue"} 0
gradle_ingest_queue{entity="requested",url="http://localhost:8081/info/ingest-queue"} 0
gradle_ingest_queue{entity="ageMins",url="http://localhost:8081/info/ingest-queue"} 0
gradle_ingest_queue{entity="requestWaitTimeSecs",url="http://localhost:8081/info/ingest-queue"} 0
gradle_ingest_queue{entity="incomingRate1m",url="http://localhost:8081/info/ingest-queue"} 0
gradle_ingest_queue{entity="incomingRate5m",url="http://localhost:8081/info/ingest-queue"} 0
gradle_ingest_queue{entity="incomingRate15m",url="http://localhost:8081/info/ingest-queue"} 0
gradle_ingest_queue{entity="processingRate1m",url="http://localhost:8081/info/ingest-queue"} 0
gradle_ingest_queue{entity="processingRate5m",url="http://localhost:8081/info/ingest-queue"} 0
gradle_ingest_queue{entity="processingRate15m",url="http://localhost:8081/info/ingest-queue"} 0
gradle_ready{entity="build_cache_node",url="http://localhost:8081/ready"} 1
gradle_ready{entity="test_distribution",url="http://localhost:8081/ready"} 1
gradle_ready{entity="enterprise_app",url="http://localhost:8081/ready"} 1
gradle_ready{entity="keycloak",url="http://localhost:8081/ready"} 1
```


Expand Down
2 changes: 1 addition & 1 deletion handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def generate_metrics(json_data, url):
for k, v in json_data.items():
# convert bool values into 0/1 representation to put into metric value
v = 1 if re.search('true', str(v), re.IGNORECASE) else 0
metrics_str += f'gradle_{last_item}_{k}{{url="{url}"}} {v}\n'
metrics_str += f'gradle_{last_item}{{entity="{k}",url="{url}"}} {v}\n'
return metrics_str


Expand Down
6 changes: 3 additions & 3 deletions prometheus/rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ groups:
- name: gradle-server-exporter
rules:
- alert: GradlePendingRequests
expr: gradle_ingest_queue_pending > 1000
expr: gradle_ingest_queue{entity="pending} > 1000
for: 10m
labels:
severity: warning
annotations:
summary: More than 1000 ({{$value}}) pending requests in the queue

- alert: GradleComponentReady
expr: count({__name__=~"gradle_ready_.*"} == 0) by(url)
expr: gradle_ready == 0
for: 10m
labels:
severity: critical
annotations:
summary: "{{$value}}% component(s) of Gradle server is(are) not in ready state"
summary: "{{$labels.entity}}% component is not in ready state"
runbook: Check {{$labels.url}} for more details
2 changes: 1 addition & 1 deletion tests/test_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def test_generate_metrics():
}
result = generate_metrics(json_data=json_data,
url=fake_url_str)
assert result == f'gradle_ingest_queue_pending{{url="{fake_url_str}"}} 0\ngradle_ingest_queue_requested{{url="{fake_url_str}"}} 0\n'
assert result == f'gradle_ingest_queue{{entity="pending",url="{fake_url_str}"}} 0\ngradle_ingest_queue{{entity="requested",url="{fake_url_str}"}} 0\n'

json_data = json.loads('{}')
result = generate_metrics(json_data=json_data,
Expand Down

0 comments on commit e38ad28

Please sign in to comment.