Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tango
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LOFAR2.0
tango
Commits
b976e9bd
Commit
b976e9bd
authored
3 years ago
by
Jan David Mol
Browse files
Options
Downloads
Patches
Plain Diff
L2SS-758
: Allow port to be configured, added more comments
parent
d197aa49
No related branches found
No related tags found
1 merge request
!305
L2SS-758: Tune prometheus archiving
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
docker-compose/tango-prometheus-exporter/code/tango-prometheus-client.py
+13
-2
13 additions, 2 deletions
...tango-prometheus-exporter/code/tango-prometheus-client.py
with
13 additions
and
2 deletions
docker-compose/tango-prometheus-exporter/code/tango-prometheus-client.py
+
13
−
2
View file @
b976e9bd
...
@@ -100,10 +100,14 @@ class CustomCollector(object):
...
@@ -100,10 +100,14 @@ class CustomCollector(object):
return
([
dev
.
dev_name
(),
attr_info
.
name
,
str_value
,
data_type
,
f
"
{
x
:
02
}
"
,
f
"
{
y
:
02
}
"
],
float_value
)
return
([
dev
.
dev_name
(),
attr_info
.
name
,
str_value
,
data_type
,
f
"
{
x
:
02
}
"
,
f
"
{
y
:
02
}
"
],
float_value
)
def
metrics_scalar
(
self
,
dev
,
attr_info
,
attr_value
):
def
metrics_scalar
(
self
,
dev
,
attr_info
,
attr_value
):
"""
Return all metrics for a given SCALAR attribute.
"""
new_metric
=
self
.
_to_metric
(
dev
,
attr_info
,
0
,
0
,
attr_value
.
value
)
new_metric
=
self
.
_to_metric
(
dev
,
attr_info
,
0
,
0
,
attr_value
.
value
)
return
[
new_metric
]
if
new_metric
else
[]
return
[
new_metric
]
if
new_metric
else
[]
def
metrics_spectrum
(
self
,
dev
,
attr_info
,
attr_value
):
def
metrics_spectrum
(
self
,
dev
,
attr_info
,
attr_value
):
"""
Return all metrics for a given SPECTRUM attribute.
"""
metrics
=
[]
metrics
=
[]
for
x
in
range
(
int
(
attr_value
.
dim_x
)):
for
x
in
range
(
int
(
attr_value
.
dim_x
)):
new_metric
=
self
.
_to_metric
(
dev
,
attr_info
,
x
,
0
,
attr_value
.
value
[
x
])
new_metric
=
self
.
_to_metric
(
dev
,
attr_info
,
x
,
0
,
attr_value
.
value
[
x
])
...
@@ -112,6 +116,8 @@ class CustomCollector(object):
...
@@ -112,6 +116,8 @@ class CustomCollector(object):
return
metrics
return
metrics
def
metrics_image
(
self
,
dev
,
attr_info
,
attr_value
):
def
metrics_image
(
self
,
dev
,
attr_info
,
attr_value
):
"""
Return all metrics for a given IMAGE attribute.
"""
metrics
=
[]
metrics
=
[]
for
y
in
range
(
int
(
attr_value
.
dim_y
)):
for
y
in
range
(
int
(
attr_value
.
dim_y
)):
for
x
in
range
(
int
(
attr_value
.
dim_x
)):
for
x
in
range
(
int
(
attr_value
.
dim_x
)):
...
@@ -124,6 +130,8 @@ class CustomCollector(object):
...
@@ -124,6 +130,8 @@ class CustomCollector(object):
return
metrics
return
metrics
def
metrics
(
self
,
dev
,
attr_info
,
attr_value
):
def
metrics
(
self
,
dev
,
attr_info
,
attr_value
):
"""
Return all metrics for a given attribute.
"""
if
attr_info
.
data_format
==
AttrDataFormat
.
SCALAR
:
if
attr_info
.
data_format
==
AttrDataFormat
.
SCALAR
:
return
self
.
metrics_scalar
(
dev
,
attr_info
,
attr_value
)
return
self
.
metrics_scalar
(
dev
,
attr_info
,
attr_value
)
elif
attr_info
.
data_format
==
AttrDataFormat
.
SPECTRUM
:
elif
attr_info
.
data_format
==
AttrDataFormat
.
SPECTRUM
:
...
@@ -134,6 +142,8 @@ class CustomCollector(object):
...
@@ -134,6 +142,8 @@ class CustomCollector(object):
return
[]
return
[]
def
device_metrics
(
self
,
device_name
):
def
device_metrics
(
self
,
device_name
):
"""
Return all metrics for a given device, as configured.
"""
dev
=
DeviceProxy
(
device_name
)
dev
=
DeviceProxy
(
device_name
)
dev
.
set_timeout_millis
(
self
.
proxy_timeout
)
dev
.
set_timeout_millis
(
self
.
proxy_timeout
)
...
@@ -167,7 +177,7 @@ class CustomCollector(object):
...
@@ -167,7 +177,7 @@ class CustomCollector(object):
return
metrics
return
metrics
def
collect
(
self
):
def
collect
(
self
):
"""
Yield all scraped metrics.
"""
"""
Yield all scraped metrics
from all devices, as configured
.
"""
logger
.
info
(
"
Start scraping
"
)
logger
.
info
(
"
Start scraping
"
)
scrape_begin
=
time
.
time
()
scrape_begin
=
time
.
time
()
...
@@ -207,13 +217,14 @@ if __name__ == '__main__':
...
@@ -207,13 +217,14 @@ if __name__ == '__main__':
parser
=
argparse
.
ArgumentParser
()
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'
-c
'
,
'
--config
'
,
type
=
str
,
required
=
True
,
help
=
'
configuration file
'
)
parser
.
add_argument
(
'
-c
'
,
'
--config
'
,
type
=
str
,
required
=
True
,
help
=
'
configuration file
'
)
parser
.
add_argument
(
'
-t
'
,
'
--timeout
'
,
type
=
int
,
required
=
False
,
default
=
250
,
help
=
'
device proxy timeout (ms)
'
)
parser
.
add_argument
(
'
-t
'
,
'
--timeout
'
,
type
=
int
,
required
=
False
,
default
=
250
,
help
=
'
device proxy timeout (ms)
'
)
parser
.
add_argument
(
'
-p
'
,
'
--port
'
,
type
=
int
,
required
=
False
,
default
=
8000
,
help
=
'
HTTP server port to open
'
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
config
=
ArchiverPolicy
.
load_config
(
args
.
config
)
config
=
ArchiverPolicy
.
load_config
(
args
.
config
)
collector
=
CustomCollector
(
config
,
proxy_timeout
=
args
.
timeout
)
collector
=
CustomCollector
(
config
,
proxy_timeout
=
args
.
timeout
)
logger
.
info
(
"
Starting server
"
)
logger
.
info
(
"
Starting server
"
)
start_http_server
(
8000
)
start_http_server
(
args
.
port
)
logger
.
info
(
"
Registering collector
"
)
logger
.
info
(
"
Registering collector
"
)
REGISTRY
.
register
(
collector
)
REGISTRY
.
register
(
collector
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment