Commit e5b6b17a authored by Matthias Kaeppler's avatar Matthias Kaeppler

Add hourly request volume metric

This is pulled from Prometheus as well.
parent 81d353bc
...@@ -666,8 +666,9 @@ appear to be associated to any of the services running, since they all appear to ...@@ -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 | | `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 | | `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 | | `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 | | `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_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_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 | | `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. ...@@ -873,6 +874,8 @@ The following is example content of the Usage Ping payload.
} }
}, },
"topology": { "topology": {
"duration_s": 0.013836685999194742,
"application_requests_per_hour": 4224,
"nodes": [ "nodes": [
{ {
"node_memory_total_bytes": 33269903360, "node_memory_total_bytes": 33269903360,
...@@ -897,8 +900,7 @@ The following is example content of the Usage Ping payload. ...@@ -897,8 +900,7 @@ The following is example content of the Usage Ping payload.
... ...
}, },
... ...
], ]
"duration_s": 0.013836685999194742
} }
} }
``` ```
...@@ -28,9 +28,18 @@ module Gitlab ...@@ -28,9 +28,18 @@ module Gitlab
def topology_fetch_all_data def topology_fetch_all_data
with_prometheus_client(fallback: {}) do |client| with_prometheus_client(fallback: {}) do |client|
{ {
application_requests_per_hour: topology_app_requests_per_hour(client),
nodes: topology_node_data(client) nodes: topology_node_data(client)
} }.compact
end
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 end
def topology_node_data(client) def topology_node_data(client)
......
...@@ -22,6 +22,7 @@ RSpec.describe Gitlab::UsageDataConcerns::Topology do ...@@ -22,6 +22,7 @@ RSpec.describe Gitlab::UsageDataConcerns::Topology do
context 'tracking node metrics' do context 'tracking node metrics' do
it 'contains node level metrics for each instance' do it 'contains node level metrics for each instance' do
expect_prometheus_api_to( expect_prometheus_api_to(
receive_app_request_volume_query,
receive_node_memory_query, receive_node_memory_query,
receive_node_cpu_count_query, receive_node_cpu_count_query,
receive_node_service_memory_rss_query, receive_node_service_memory_rss_query,
...@@ -32,6 +33,7 @@ RSpec.describe Gitlab::UsageDataConcerns::Topology do ...@@ -32,6 +33,7 @@ RSpec.describe Gitlab::UsageDataConcerns::Topology do
expect(subject[:topology]).to eq({ expect(subject[:topology]).to eq({
duration_s: 0, duration_s: 0,
application_requests_per_hour: 36,
nodes: [ nodes: [
{ {
node_memory_total_bytes: 512, node_memory_total_bytes: 512,
...@@ -76,6 +78,7 @@ RSpec.describe Gitlab::UsageDataConcerns::Topology do ...@@ -76,6 +78,7 @@ RSpec.describe Gitlab::UsageDataConcerns::Topology do
context 'and some node memory metrics are missing' do context 'and some node memory metrics are missing' do
it 'removes the respective entries' do it 'removes the respective entries' do
expect_prometheus_api_to( expect_prometheus_api_to(
receive_app_request_volume_query(result: []),
receive_node_memory_query(result: []), receive_node_memory_query(result: []),
receive_node_cpu_count_query, receive_node_cpu_count_query,
receive_node_service_memory_rss_query(result: []), receive_node_service_memory_rss_query(result: []),
...@@ -149,6 +152,17 @@ RSpec.describe Gitlab::UsageDataConcerns::Topology do ...@@ -149,6 +152,17 @@ RSpec.describe Gitlab::UsageDataConcerns::Topology do
end end
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) def receive_node_memory_query(result: nil)
receive(:query) receive(:query)
.with(/node_memory_total_bytes/, an_instance_of(Hash)) .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