Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
gitlab-org
gitlab-exporter
Commits
aa43c78d
Commit
aa43c78d
authored
Apr 25, 2019
by
Ahmad Sherif
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add RemoteMirrorsProber
Related to
https://gitlab.com/gitlab-com/gl-infra/infrastructure/issues/5313
parent
5a05b469
Pipeline
#110413
passed with stage
in 1 minute and 4 seconds
Changes
6
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
80 additions
and
2 deletions
+80
-2
Gemfile.lock
Gemfile.lock
+1
-1
README.md
README.md
+2
-0
config/gitlab-monitor.yml.example
config/gitlab-monitor.yml.example
+7
-0
lib/gitlab_monitor/database.rb
lib/gitlab_monitor/database.rb
+1
-0
lib/gitlab_monitor/database/remote_mirrors.rb
lib/gitlab_monitor/database/remote_mirrors.rb
+68
-0
lib/gitlab_monitor/version.rb
lib/gitlab_monitor/version.rb
+1
-1
No files found.
Gemfile.lock
View file @
aa43c78d
PATH
remote: .
specs:
gitlab-monitor (3.
5
.0)
gitlab-monitor (3.
6
.0)
connection_pool (~> 2.2.1)
pg (~> 1.1)
quantile (~> 0.2.0)
...
...
README.md
View file @
aa43c78d
...
...
@@ -27,6 +27,8 @@ metrics.
*
[
Bloat
](
lib/gitlab_monitor/database/bloat.rb
)
--
`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`
1.
Git
*
[
git pull/push timings
](
lib/gitlab_monitor/git.rb
)
--
`git_pull_time_milliseconds`
,
`git_push_time_milliseconds`
...
...
config/gitlab-monitor.yml.example
View file @
aa43c78d
...
...
@@ -60,6 +60,13 @@ probes:
- soft_deleted_projects
- orphaned_projects
- uploads
remote_mirrors:
class_name: Database::RemoteMirrors
<<: *db_common
opts:
<<: *db_common_opts
project_ids:
- 1
process: &process
methods:
...
...
lib/gitlab_monitor/database.rb
View file @
aa43c78d
...
...
@@ -7,6 +7,7 @@ module GitLab
autoload
:TuplesProber
,
"gitlab_monitor/database/tuple_stats"
autoload
:RowCountProber
,
"gitlab_monitor/database/row_count"
autoload
:BloatProber
,
"gitlab_monitor/database/bloat"
autoload
:RemoteMirrorsProber
,
"gitlab_monitor/database/remote_mirrors"
end
end
end
lib/gitlab_monitor/database/remote_mirrors.rb
0 → 100644
View file @
aa43c78d
module
GitLab
module
Monitor
module
Database
# 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
FROM remote_mirrors WHERE project_id IN (%s) AND enabled = 't'
SQL
def
initialize
(
args
)
super
(
args
)
@project_ids
=
args
[
:project_ids
]
end
def
run
return
if
@project_ids
.
nil?
||
@project_ids
.
empty?
execute
(
QUERY
%
[
@project_ids
.
join
(
","
)])
# rubocop:disable Style/FormatString
end
private
def
execute
(
query
)
with_connection_pool
do
|
conn
|
conn
.
exec
(
query
)
end
rescue
PG
::
UndefinedTable
,
PG
::
UndefinedColumn
nil
end
end
# The prober which is called when gathering metrics
class
RemoteMirrorsProber
def
initialize
(
opts
,
metrics:
PrometheusMetrics
.
new
)
@metrics
=
metrics
@collector
=
RemoteMirrorsCollector
.
new
(
connection_string:
opts
[
:connection_string
],
project_ids:
opts
[
:project_ids
]
)
end
def
probe_db
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
,
project_id:
row
[
"project_id"
],
url:
row
[
"url"
]
)
end
self
rescue
PG
::
ConnectionBad
self
end
def
write_to
(
target
)
target
.
write
(
@metrics
.
to_s
)
end
end
end
end
end
lib/gitlab_monitor/version.rb
View file @
aa43c78d
module
GitLab
module
Monitor
VERSION
=
"3.
5
.0"
.
freeze
VERSION
=
"3.
6
.0"
.
freeze
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment