Commit b2a85958 authored by Ahmad Sherif's avatar Ahmad Sherif

Add project_remote_mirror_last_successful_update_time_seconds metric

parent 47d2d9f5
Pipeline #182289 passed with stage
in 50 seconds
PATH PATH
remote: . remote: .
specs: specs:
gitlab-monitor (3.6.0) gitlab-monitor (3.7.0)
connection_pool (~> 2.2.1) connection_pool (~> 2.2.1)
pg (~> 1.1) pg (~> 1.1)
quantile (~> 0.2.0) quantile (~> 0.2.0)
......
...@@ -28,7 +28,7 @@ metrics. ...@@ -28,7 +28,7 @@ metrics.
`gitlab_database_bloat_$type_$key` with type `btree` (index bloat) or `table` `gitlab_database_bloat_$type_$key` with type `btree` (index bloat) or `table`
(table bloat) and keys `bloat_ratio bloat_size extra_size real_size` (see below) (table bloat) and keys `bloat_ratio bloat_size extra_size real_size` (see below)
* [Remote mirrors](lib/gitlab_monitor/database/remote_mirrors.rb) -- * [Remote mirrors](lib/gitlab_monitor/database/remote_mirrors.rb) --
`project_remote_mirror_last_successful_update_time_seconds` `project_remote_mirror_last_successful_update_time_seconds`, `project_remote_mirror_last_update_time_seconds`
1. Git 1. Git
* [git pull/push timings](lib/gitlab_monitor/git.rb) -- * [git pull/push timings](lib/gitlab_monitor/git.rb) --
`git_pull_time_milliseconds`, `git_push_time_milliseconds` `git_pull_time_milliseconds`, `git_push_time_milliseconds`
......
...@@ -4,7 +4,9 @@ module GitLab ...@@ -4,7 +4,9 @@ module GitLab
# A helper class to collect remote mirrors metrics. # A helper class to collect remote mirrors metrics.
class RemoteMirrorsCollector < Base class RemoteMirrorsCollector < Base
QUERY = <<~SQL.freeze QUERY = <<~SQL.freeze
SELECT project_id, url, EXTRACT(EPOCH FROM last_successful_update_at) AS last_successful_update_at SELECT project_id, url,
EXTRACT(EPOCH FROM last_successful_update_at) AS last_successful_update_at,
EXTRACT(EPOCH FROM last_update_at) AS last_update_at
FROM remote_mirrors WHERE project_id IN (%s) AND enabled = 't' FROM remote_mirrors WHERE project_id IN (%s) AND enabled = 't'
SQL SQL
...@@ -41,14 +43,18 @@ module GitLab ...@@ -41,14 +43,18 @@ module GitLab
) )
end end
def probe_db def probe_db # rubocop:disable Metrics/MethodLength
results = @collector.run results = @collector.run
results.to_a.each do |row| results.to_a.each do |row|
last_successful_update_at = row.delete("last_successful_update_at").to_i
@metrics.add( @metrics.add(
"project_remote_mirror_last_successful_update_time_seconds", "project_remote_mirror_last_successful_update_time_seconds",
last_successful_update_at, row["last_successful_update_at"].to_i,
project_id: row["project_id"],
url: row["url"]
)
@metrics.add(
"project_remote_mirror_last_update_time_seconds",
row["last_update_at"].to_i,
project_id: row["project_id"], project_id: row["project_id"],
url: row["url"] url: row["url"]
) )
......
module GitLab module GitLab
module Monitor module Monitor
VERSION = "3.6.0".freeze VERSION = "3.7.0".freeze
end end
end end
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