Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
08461c15
Commit
08461c15
authored
Jan 05, 2018
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge migrations and fix schema.rb + add required fields to prometheus metrics
parent
dda417bf
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
20 deletions
+18
-20
app/models/prometheus_metric.rb
app/models/prometheus_metric.rb
+10
-2
db/migrate/20180101160629_create_prometheus_metrics.rb
db/migrate/20180101160629_create_prometheus_metrics.rb
+4
-3
db/migrate/20180104215427_add_group_to_prometheus_metrics.rb
db/migrate/20180104215427_add_group_to_prometheus_metrics.rb
+0
-12
db/schema.rb
db/schema.rb
+4
-3
No files found.
app/models/prometheus_metric.rb
View file @
08461c15
...
...
@@ -4,10 +4,18 @@ class PrometheusMetric < ActiveRecord::Base
validates
:title
,
presence:
true
validates
:query
,
presence:
true
validates
:group
,
presence:
true
GROUP_NAMES
=
{
business_metrics:
'Business metrics'
,
response:
'Response metrics'
,
system:
'System metrics'
}.
freeze
def
self
.
to_grouped_query_metrics
self
.
all
.
group_by
(
&
:group
).
map
do
|
name
,
metrics
|
[
name
,
metrics
.
map
(
&
:to_query_metric
)]
self
.
all
.
group_by
(
&
:group
).
map
do
|
group
,
metrics
|
group
||=
:business
[
GROUP_NAMES
[
group
],
metrics
.
map
(
&
:to_query_metric
)]
end
end
...
...
db/migrate/201
71214
160629_create_prometheus_metrics.rb
→
db/migrate/201
80101
160629_create_prometheus_metrics.rb
View file @
08461c15
...
...
@@ -2,12 +2,13 @@ class CreatePrometheusMetrics < ActiveRecord::Migration
def
change
create_table
:prometheus_metrics
do
|
t
|
t
.
references
:project
,
index:
true
,
foreign_key:
true
t
.
string
:title
t
.
string
:query
t
.
string
:title
,
null:
false
t
.
string
:query
,
null:
false
t
.
string
:y_label
t
.
string
:unit
t
.
string
:legend
t
.
integer
:group
,
null:
false
t
.
index
:group
t
.
timestamps
null:
false
end
end
...
...
db/migrate/20180104215427_add_group_to_prometheus_metrics.rb
deleted
100644 → 0
View file @
dda417bf
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
AddGroupToPrometheusMetrics
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
def
change
add_column
:prometheus_metrics
,
:group
,
:integer
add_index
:prometheus_metrics
,
:group
end
end
db/schema.rb
View file @
08461c15
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
2018010
4215427
)
do
ActiveRecord
::
Schema
.
define
(
version:
2018010
1160629
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
@@ -1895,11 +1895,12 @@ ActiveRecord::Schema.define(version: 20180104215427) do
create_table
"prometheus_metrics"
,
force: :cascade
do
|
t
|
t
.
integer
"project_id"
t
.
string
"title"
t
.
string
"query"
t
.
string
"title"
,
null:
false
t
.
string
"query"
,
null:
false
t
.
string
"y_label"
t
.
string
"unit"
t
.
string
"legend"
t
.
integer
"group"
,
null:
false
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
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