Commit fb177226 authored by Sean McGivern's avatar Sean McGivern

Merge branch '217698-usage-ping-app-request-volume' into 'master'

Usage Ping: Add hourly application request volume

Closes #217698

See merge request gitlab-org/gitlab!35418
parents 7ced294f e5b6b17a
......@@ -666,8 +666,9 @@ appear to be associated to any of the services running, since they all appear to
| `clusters_applications_runner` | `usage_activity_by_stage` | `verify` | | | Unique clusters with Runner enabled |
| `projects_reporting_ci_cd_back_to_github: 0` | `usage_activity_by_stage` | `verify` | | | Unique projects with a GitHub pipeline enabled |
| `merge_requests_users` | `usage_activity_by_stage_monthly` | `create` | | | Unique count of users who used a merge request |
| `nodes` | `topology` | `enablement` | | | The list of server nodes on which GitLab components are running |
| `duration_s` | `topology` | `enablement` | | | Time it took to collect topology data |
| `application_requests_per_hour` | `topology` | `enablement` | | | Number of requests to the web application per hour |
| `nodes` | `topology` | `enablement` | | | The list of server nodes on which GitLab components are running |
| `node_memory_total_bytes` | `topology > nodes` | `enablement` | | | The total available memory of this node |
| `node_cpus` | `topology > nodes` | `enablement` | | | The number of CPU cores of this node |
| `node_services` | `topology > nodes` | `enablement` | | | The list of GitLab services running on this node |
......@@ -873,6 +874,8 @@ The following is example content of the Usage Ping payload.
}
},
"topology": {
"duration_s": 0.013836685999194742,
"application_requests_per_hour": 4224,
"nodes": [
{
"node_memory_total_bytes": 33269903360,
......@@ -897,8 +900,7 @@ The following is example content of the Usage Ping payload.
...
},
...
],
"duration_s": 0.013836685999194742
]
}
}
```
......@@ -28,11 +28,20 @@ module Gitlab
def topology_fetch_all_data
with_prometheus_client(fallback: {}) do |client|
{
application_requests_per_hour: topology_app_requests_per_hour(client),
nodes: topology_node_data(client)
}
}.compact
end
end
def topology_app_requests_per_hour(client)
result = client.query(one_week_average('gitlab_usage_ping:ops:rate5m')).first
return unless result
# the metric is recorded as a per-second rate
(result['value'].last.to_f * 1.hour).to_i
end
def topology_node_data(client)
# node-level data
by_instance_mem = topology_node_memory(client)
......
......@@ -22,6 +22,7 @@ RSpec.describe Gitlab::UsageDataConcerns::Topology do
context 'tracking node metrics' do
it 'contains node level metrics for each instance' do
expect_prometheus_api_to(
receive_app_request_volume_query,
receive_node_memory_query,
receive_node_cpu_count_query,
receive_node_service_memory_rss_query,
......@@ -32,6 +33,7 @@ RSpec.describe Gitlab::UsageDataConcerns::Topology do
expect(subject[:topology]).to eq({
duration_s: 0,
application_requests_per_hour: 36,
nodes: [
{
node_memory_total_bytes: 512,
......@@ -76,6 +78,7 @@ RSpec.describe Gitlab::UsageDataConcerns::Topology do
context 'and some node memory metrics are missing' do
it 'removes the respective entries' do
expect_prometheus_api_to(
receive_app_request_volume_query(result: []),
receive_node_memory_query(result: []),
receive_node_cpu_count_query,
receive_node_service_memory_rss_query(result: []),
......@@ -149,6 +152,17 @@ RSpec.describe Gitlab::UsageDataConcerns::Topology do
end
end
def receive_app_request_volume_query(result: nil)
receive(:query)
.with(/gitlab_usage_ping:ops:rate/)
.and_return(result || [
{
'metric' => { 'component' => 'http_requests', 'service' => 'workhorse' },
'value' => [1000, '0.01']
}
])
end
def receive_node_memory_query(result: nil)
receive(:query)
.with(/node_memory_total_bytes/, an_instance_of(Hash))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment