From 200b5131dbfaeb08a8d5963a909abe68ff541689 Mon Sep 17 00:00:00 2001 From: Denis Shevchenko Date: Mon, 25 Jan 2021 19:13:47 +0400 Subject: [PATCH] CAD-2196: simplify node configuration for trace forwarder --- .../src/Cardano/Node/Configuration/Logging.hs | 18 +++++++++++++++++- .../chairman/byron-shelley/configuration.yaml | 10 ---------- .../chairman/defaults/simpleview/config-0.yaml | 12 ------------ .../chairman/defaults/simpleview/config-1.yaml | 12 ------------ .../chairman/defaults/simpleview/config-2.yaml | 12 ------------ .../chairman/shelly-only/configuration.yaml | 10 ---------- .../defaults/byron-mainnet/configuration.yaml | 10 ---------- .../defaults/byron-staging/configuration.yaml | 16 ++-------------- .../defaults/byron-testnet/configuration.yaml | 16 ++-------------- .../defaults/simpleview/config-0.yaml | 12 ------------ .../defaults/simpleview/config-1.yaml | 12 ------------ .../defaults/simpleview/config-2.yaml | 12 ------------ scripts/lite/configuration/shelley-1.yaml | 10 ---------- scripts/lite/configuration/shelley-2.yaml | 10 ---------- scripts/lite/configuration/shelley-3.yaml | 10 ---------- 15 files changed, 21 insertions(+), 161 deletions(-) diff --git a/cardano-node/src/Cardano/Node/Configuration/Logging.hs b/cardano-node/src/Cardano/Node/Configuration/Logging.hs index 8c7a3538481..8abba49811f 100644 --- a/cardano-node/src/Cardano/Node/Configuration/Logging.hs +++ b/cardano-node/src/Cardano/Node/Configuration/Logging.hs @@ -42,7 +42,7 @@ import Cardano.BM.Configuration (Configuration) import qualified Cardano.BM.Configuration as Config import qualified Cardano.BM.Configuration.Model as Config import Cardano.BM.Data.Aggregated (Measurable (..)) -import Cardano.BM.Data.Backend (Backend, BackendKind) +import Cardano.BM.Data.Backend (Backend, BackendKind (..)) import Cardano.BM.Data.LogItem (LOContent (..), LOMeta (..), LoggerName) import qualified Cardano.BM.Observer.Monadic as Monadic import qualified Cardano.BM.Observer.STM as Stm @@ -179,6 +179,12 @@ createLoggingLayer ver nodeConfig' p = do Config.getForwardTo logConfig >>= \forwardTo -> when (isJust forwardTo) $ do + -- Since the configuration contains 'traceForwardTo' section, + -- node's information (metrics/peers/errors) should be forwarded + -- to an external process (for example, RTView). + + -- Activate TraceForwarder plugin (there is no need to add 'TraceForwarderBK' + -- to 'setupBackends' list). nodeStartTime <- getCurrentTime Cardano.BM.Backend.TraceForwarder.plugin logConfig trace @@ -187,6 +193,16 @@ createLoggingLayer ver nodeConfig' p = do (nodeBasicInfo nodeConfig p nodeStartTime) >>= loadPlugin switchBoard + -- Forward all the metrics/peers/errors to 'TraceForwarderBK' using 'mapBackends'. + -- If 'TraceForwarderBK' is already added in 'mapBackends' - ignore it. + let metricsLogger = "cardano.node.metrics" -- All metrics and peers info are here. + errorsLoggers = "cardano.node" -- All errors (messages with 'Warning+' severity) are here. + + forM_ [metricsLogger, errorsLoggers] $ \loggerName -> + Config.getBackends logConfig loggerName >>= \backends -> + when (TraceForwarderBK `notElem` backends) $ + Config.setBackends logConfig loggerName $ Just (TraceForwarderBK : backends) + Cardano.BM.Backend.Aggregation.plugin logConfig trace switchBoard >>= loadPlugin switchBoard Cardano.BM.Backend.Monitoring.plugin logConfig trace switchBoard diff --git a/configuration/chairman/byron-shelley/configuration.yaml b/configuration/chairman/byron-shelley/configuration.yaml index c76f9ba34de..240d41e5fdc 100644 --- a/configuration/chairman/byron-shelley/configuration.yaml +++ b/configuration/chairman/byron-shelley/configuration.yaml @@ -255,17 +255,7 @@ options: # go to the default backend, only to the explicitly listed backends. mapBackends: cardano.node.metrics: - - TraceForwarderBK - EKGViewBK - cardano.node.release: - - TraceForwarderBK - - KatipBK - cardano.node.version: - - TraceForwarderBK - - KatipBK - cardano.node.commit: - - TraceForwarderBK - - KatipBK # redirects traced values to a specific scribe which is identified by its # type and its name, separated by "::": diff --git a/configuration/chairman/defaults/simpleview/config-0.yaml b/configuration/chairman/defaults/simpleview/config-0.yaml index fdf827b9afd..0d72a4452e4 100644 --- a/configuration/chairman/defaults/simpleview/config-0.yaml +++ b/configuration/chairman/defaults/simpleview/config-0.yaml @@ -10,9 +10,6 @@ rotation: # these backends are initialized: setupBackends: - KatipBK -# Uncomment it to enable trace forwarder backend, if the node should -# forward metrics to an external process. -# - TraceForwarderBK # if not indicated otherwise, then messages are passed to these backends: defaultBackends: @@ -47,15 +44,6 @@ options: mapBackends: cardano.node.metrics: - EKGViewBK -# Uncomment it to send 'cardano.node.metrics' to 'TraceForwarderBK' as well. -# - TraceForwarderBK -# Uncomment it to send node's release, version and commit to 'TraceForwarderBK'. -# cardano.node.release: -# - TraceForwarderBK -# cardano.node.version: -# - TraceForwarderBK -# cardano.node.commit: -# - TraceForwarderBK # Uncomment it to forward node's metrics to remote socket '127.0.0.1:2997'. # traceForwardTo: diff --git a/configuration/chairman/defaults/simpleview/config-1.yaml b/configuration/chairman/defaults/simpleview/config-1.yaml index 110ec9be19b..bdefc2aa815 100644 --- a/configuration/chairman/defaults/simpleview/config-1.yaml +++ b/configuration/chairman/defaults/simpleview/config-1.yaml @@ -10,9 +10,6 @@ rotation: # these backends are initialized: setupBackends: - KatipBK -# Uncomment it to enable trace forwarder backend, if the node should -# forward metrics to an external process. -# - TraceForwarderBK # if not indicated otherwise, then messages are passed to these backends: defaultBackends: @@ -47,15 +44,6 @@ options: mapBackends: cardano.node.metrics: - EKGViewBK -# Uncomment it to send 'cardano.node.metrics' to 'TraceForwarderBK' as well. -# - TraceForwarderBK -# Uncomment it to send node's release, version and commit to 'TraceForwarderBK'. -# cardano.node.release: -# - TraceForwarderBK -# cardano.node.version: -# - TraceForwarderBK -# cardano.node.commit: -# - TraceForwarderBK # Uncomment it to forward node's metrics to remote socket '127.0.0.1:2998'. # traceForwardTo: diff --git a/configuration/chairman/defaults/simpleview/config-2.yaml b/configuration/chairman/defaults/simpleview/config-2.yaml index c124dd8d7eb..03f255ad062 100644 --- a/configuration/chairman/defaults/simpleview/config-2.yaml +++ b/configuration/chairman/defaults/simpleview/config-2.yaml @@ -10,9 +10,6 @@ rotation: # these backends are initialized: setupBackends: - KatipBK -# Uncomment it to enable trace forwarder backend, if the node should -# forward metrics to an external process. -# - TraceForwarderBK # if not indicated otherwise, then messages are passed to these backends: defaultBackends: @@ -47,15 +44,6 @@ options: mapBackends: cardano.node.metrics: - EKGViewBK -# Uncomment it to send 'cardano.node.metrics' to 'TraceForwarderBK' as well. -# - TraceForwarderBK -# Uncomment it to send node's release, version and commit to 'TraceForwarderBK'. -# cardano.node.release: -# - TraceForwarderBK -# cardano.node.version: -# - TraceForwarderBK -# cardano.node.commit: -# - TraceForwarderBK # Uncomment it to forward node's metrics to remote socket '127.0.0.1:2999'. # traceForwardTo: diff --git a/configuration/chairman/shelly-only/configuration.yaml b/configuration/chairman/shelly-only/configuration.yaml index e1056321043..85c33ba28fc 100644 --- a/configuration/chairman/shelly-only/configuration.yaml +++ b/configuration/chairman/shelly-only/configuration.yaml @@ -246,17 +246,7 @@ options: # go to the default backend, only to the explicitly listed backends. mapBackends: cardano.node.metrics: - - TraceForwarderBK - EKGViewBK - cardano.node.release: - - TraceForwarderBK - - KatipBK - cardano.node.version: - - TraceForwarderBK - - KatipBK - cardano.node.commit: - - TraceForwarderBK - - KatipBK # redirects traced values to a specific scribe which is identified by its # type and its name, separated by "::": diff --git a/configuration/defaults/byron-mainnet/configuration.yaml b/configuration/defaults/byron-mainnet/configuration.yaml index 4202b305f27..d5704dde52c 100644 --- a/configuration/defaults/byron-mainnet/configuration.yaml +++ b/configuration/defaults/byron-mainnet/configuration.yaml @@ -243,17 +243,7 @@ options: # go to the default backend, only to the explicitly listed backends. mapBackends: cardano.node.metrics: - - TraceForwarderBK - EKGViewBK - cardano.node.release: - - TraceForwarderBK - - KatipBK - cardano.node.version: - - TraceForwarderBK - - KatipBK - cardano.node.commit: - - TraceForwarderBK - - KatipBK # redirects traced values to a specific scribe which is identified by its # type and its name, separated by "::": diff --git a/configuration/defaults/byron-staging/configuration.yaml b/configuration/defaults/byron-staging/configuration.yaml index 86ff92eefa6..0ed3feaadec 100644 --- a/configuration/defaults/byron-staging/configuration.yaml +++ b/configuration/defaults/byron-staging/configuration.yaml @@ -60,12 +60,9 @@ TracingVerbosity: NormalVerbosity # This setting lists the backends that will be available to use in the # configuration below. The logging backend is called Katip. Also enable the EKG # backend if you want to use the EKG or Prometheus monitoring interfaces. -# You can also enable trace forwarder backend if node should send the metrics -# to an external process. setupBackends: - KatipBK # - EKGViewBK -# - TraceForwarderBK # This specifies the default backends that trace output is sent to if it # is not specifically configured to be sent to other backends. @@ -220,17 +217,8 @@ options: mapBackends: cardano.node.metrics: - EKGViewBK - # Uncomment it to send 'cardano.node.metrics' to 'TraceForwarderBK' as well. - # - TraceForwarderBK - # Uncomment it to send node's release, version and commit to 'TraceForwarderBK'. - # cardano.node.release: - # - TraceForwarderBK - # cardano.node.version: - # - TraceForwarderBK - # cardano.node.commit: - # - TraceForwarderBK - -# If 'TraceForwarderBK' is enabled, uncomment it to forward node's metrics + +# Uncomment it to forward node's metrics # to remote socket '127.0.0.1:2997'. # traceForwardTo: # tag: RemoteSocket diff --git a/configuration/defaults/byron-testnet/configuration.yaml b/configuration/defaults/byron-testnet/configuration.yaml index 8cfaa468c16..15eccfc9dc4 100644 --- a/configuration/defaults/byron-testnet/configuration.yaml +++ b/configuration/defaults/byron-testnet/configuration.yaml @@ -60,12 +60,9 @@ TracingVerbosity: NormalVerbosity # This setting lists the backends that will be available to use in the # configuration below. The logging backend is called Katip. Also enable the EKG # backend if you want to use the EKG or Prometheus monitoring interfaces. -# You can also enable trace forwarder backend if node should send the metrics -# to an external process. setupBackends: - KatipBK # - EKGViewBK -# - TraceForwarderBK # This specifies the default backends that trace output is sent to if it # is not specifically configured to be sent to other backends. @@ -220,17 +217,8 @@ options: mapBackends: cardano.node.metrics: - EKGViewBK - # Uncomment it to send 'cardano.node.metrics' to 'TraceForwarderBK' as well. - # - TraceForwarderBK - # Uncomment it to send node's release, version and commit to 'TraceForwarderBK'. - # cardano.node.release: - # - TraceForwarderBK - # cardano.node.version: - # - TraceForwarderBK - # cardano.node.commit: - # - TraceForwarderBK - -# If 'TraceForwarderBK' is enabled, uncomment it to forward node's metrics + +# Uncomment it to forward node's metrics # to remote socket '127.0.0.1:2997'. # traceForwardTo: # tag: RemoteSocket diff --git a/configuration/defaults/simpleview/config-0.yaml b/configuration/defaults/simpleview/config-0.yaml index b6f20b27ed7..bb906ff1b9e 100644 --- a/configuration/defaults/simpleview/config-0.yaml +++ b/configuration/defaults/simpleview/config-0.yaml @@ -10,9 +10,6 @@ rotation: # these backends are initialized: setupBackends: - KatipBK -# Uncomment it to enable trace forwarder backend, if the node should -# forward metrics to an external process. -# - TraceForwarderBK # if not indicated otherwise, then messages are passed to these backends: defaultBackends: @@ -47,15 +44,6 @@ options: mapBackends: cardano.node.metrics: - EKGViewBK -# Uncomment it to send 'cardano.node.metrics' to 'TraceForwarderBK' as well. -# - TraceForwarderBK -# Uncomment it to send node's release, version and commit to 'TraceForwarderBK'. -# cardano.node.release: -# - TraceForwarderBK -# cardano.node.version: -# - TraceForwarderBK -# cardano.node.commit: -# - TraceForwarderBK # Uncomment it to forward node's metrics to remote socket '127.0.0.1:2997'. # traceForwardTo: diff --git a/configuration/defaults/simpleview/config-1.yaml b/configuration/defaults/simpleview/config-1.yaml index 73a9c6ff196..929b0bf0007 100644 --- a/configuration/defaults/simpleview/config-1.yaml +++ b/configuration/defaults/simpleview/config-1.yaml @@ -10,9 +10,6 @@ rotation: # these backends are initialized: setupBackends: - KatipBK -# Uncomment it to enable trace forwarder backend, if the node should -# forward metrics to an external process. -# - TraceForwarderBK # if not indicated otherwise, then messages are passed to these backends: defaultBackends: @@ -47,15 +44,6 @@ options: mapBackends: cardano.node.metrics: - EKGViewBK -# Uncomment it to send 'cardano.node.metrics' to 'TraceForwarderBK' as well. -# - TraceForwarderBK -# Uncomment it to send node's release, version and commit to 'TraceForwarderBK'. -# cardano.node.release: -# - TraceForwarderBK -# cardano.node.version: -# - TraceForwarderBK -# cardano.node.commit: -# - TraceForwarderBK # Uncomment it to forward node's metrics to remote socket '127.0.0.1:2998'. # traceForwardTo: diff --git a/configuration/defaults/simpleview/config-2.yaml b/configuration/defaults/simpleview/config-2.yaml index 5c7e09afbfe..8b252afc2c6 100644 --- a/configuration/defaults/simpleview/config-2.yaml +++ b/configuration/defaults/simpleview/config-2.yaml @@ -10,9 +10,6 @@ rotation: # these backends are initialized: setupBackends: - KatipBK -# Uncomment it to enable trace forwarder backend, if the node should -# forward metrics to an external process. -# - TraceForwarderBK # if not indicated otherwise, then messages are passed to these backends: defaultBackends: @@ -47,15 +44,6 @@ options: mapBackends: cardano.node.metrics: - EKGViewBK -# Uncomment it to send 'cardano.node.metrics' to 'TraceForwarderBK' as well. -# - TraceForwarderBK -# Uncomment it to send node's release, version and commit to 'TraceForwarderBK'. -# cardano.node.release: -# - TraceForwarderBK -# cardano.node.version: -# - TraceForwarderBK -# cardano.node.commit: -# - TraceForwarderBK # Uncomment it to forward node's metrics to remote socket '127.0.0.1:2999'. # traceForwardTo: diff --git a/scripts/lite/configuration/shelley-1.yaml b/scripts/lite/configuration/shelley-1.yaml index 59ca995f3bd..00514723bde 100644 --- a/scripts/lite/configuration/shelley-1.yaml +++ b/scripts/lite/configuration/shelley-1.yaml @@ -241,17 +241,7 @@ options: # go to the default backend, only to the explicitly listed backends. mapBackends: cardano.node.metrics: - - TraceForwarderBK - EKGViewBK - cardano.node.release: - - TraceForwarderBK - - KatipBK - cardano.node.version: - - TraceForwarderBK - - KatipBK - cardano.node.commit: - - TraceForwarderBK - - KatipBK # redirects traced values to a specific scribe which is identified by its # type and its name, separated by "::": diff --git a/scripts/lite/configuration/shelley-2.yaml b/scripts/lite/configuration/shelley-2.yaml index 59ca995f3bd..00514723bde 100644 --- a/scripts/lite/configuration/shelley-2.yaml +++ b/scripts/lite/configuration/shelley-2.yaml @@ -241,17 +241,7 @@ options: # go to the default backend, only to the explicitly listed backends. mapBackends: cardano.node.metrics: - - TraceForwarderBK - EKGViewBK - cardano.node.release: - - TraceForwarderBK - - KatipBK - cardano.node.version: - - TraceForwarderBK - - KatipBK - cardano.node.commit: - - TraceForwarderBK - - KatipBK # redirects traced values to a specific scribe which is identified by its # type and its name, separated by "::": diff --git a/scripts/lite/configuration/shelley-3.yaml b/scripts/lite/configuration/shelley-3.yaml index 59ca995f3bd..00514723bde 100644 --- a/scripts/lite/configuration/shelley-3.yaml +++ b/scripts/lite/configuration/shelley-3.yaml @@ -241,17 +241,7 @@ options: # go to the default backend, only to the explicitly listed backends. mapBackends: cardano.node.metrics: - - TraceForwarderBK - EKGViewBK - cardano.node.release: - - TraceForwarderBK - - KatipBK - cardano.node.version: - - TraceForwarderBK - - KatipBK - cardano.node.commit: - - TraceForwarderBK - - KatipBK # redirects traced values to a specific scribe which is identified by its # type and its name, separated by "::":