Commit a985abf3 authored by Ahmad Sherif's avatar Ahmad Sherif
Browse files

Merge branch 'add-project_remote_mirror_last_update_time_seconds' into 'master'

Add project_remote_mirror_last_successful_update_time_seconds metric

See merge request gitlab-org/gitlab-monitor!91
parents 47d2d9f5 b2a85958
Pipeline #110459 passed with stage
in 51 seconds
PATH
remote: .
specs:
gitlab-monitor (3.6.0)
gitlab-monitor (3.7.0)
connection_pool (~> 2.2.1)
pg (~> 1.1)
quantile (~> 0.2.0)
......
......@@ -28,7 +28,7 @@ metrics.
`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)
* [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
* [git pull/push timings](lib/gitlab_monitor/git.rb) --
`git_pull_time_milliseconds`, `git_push_time_milliseconds`
......
......@@ -4,7 +4,9 @@ module GitLab
# A helper class to collect remote mirrors metrics.
class RemoteMirrorsCollector < Base
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'
SQL
......@@ -41,14 +43,18 @@ module GitLab
)
end
def probe_db
def probe_db # rubocop:disable Metrics/MethodLength
results = @collector.run
results.to_a.each do |row|
last_successful_update_at = row.delete("last_successful_update_at").to_i
@metrics.add(
"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"],
url: row["url"]
)
......
module GitLab
module Monitor
VERSION = "3.6.0".freeze
VERSION = "3.7.0".freeze
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