Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
arthur-zzz
noc
Commits
f6e67761
Commit
f6e67761
authored
Jun 17, 2021
by
Andrey Vertiprahov
Browse files
Merge branch 'fix-mx-mirror-enable-check' into 'master'
Mirror to MX metrics use service pub. See merge request
noc/noc!5464
parents
d29f8f1d
a7984614
Changes
1
Hide whitespace changes
Inline
Side-by-side
core/service/base.py
View file @
f6e67761
...
...
@@ -53,7 +53,8 @@ from noc.core.liftbridge.queuebuffer import QBuffer
from
noc.core.liftbridge.message
import
Message
from
noc.core.ioloop.util
import
setup_asyncio
from
noc.core.ioloop.timers
import
PeriodicCallback
from
noc.core.mx
import
send_message
from
noc.core.mx
import
MX_STREAM
,
get_mx_partitions
,
MX_MESSAGE_TYPE
,
MX_SHARDING_KEY
from
noc.core.comp
import
smart_bytes
from
.rpc
import
RPCProxy
from
.loader
import
set_service
...
...
@@ -928,14 +929,20 @@ class BaseService(object):
stream
=
f
"ch.
{
table
}
"
,
partition
=
key
%
self
.
n_metrics_partitions
,
data
=
metrics
)
# Mirror to MX
if
config
.
message
.
enable_metrics
and
(
not
self
.
mx_metrics_scopes
or
table
in
self
.
mx_metrics_scopes
if
(
config
.
message
.
enable_metrics
and
self
.
mx_metrics_scopes
and
table
in
self
.
mx_metrics_scopes
):
send_message
(
data
=
[
self
.
mx_metrics_scopes
[
table
](
m
)
for
m
in
metrics
],
message_type
=
"metrics"
,
headers
=
{},
sharding_key
=
key
%
self
.
mx_partitions
,
n_partitions
=
get_mx_partitions
()
self
.
publish
(
value
=
orjson
.
dumps
([
self
.
mx_metrics_scopes
[
table
](
m
)
for
m
in
metrics
]),
stream
=
MX_STREAM
,
partition
=
key
%
n_partitions
,
headers
=
{
MX_MESSAGE_TYPE
:
b
"metrics"
,
MX_SHARDING_KEY
:
smart_bytes
(
key
),
},
)
def
start_telemetry_callback
(
self
)
->
None
:
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment