-
Notifications
You must be signed in to change notification settings - Fork 724
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2865: CAD-2907: add locli r=deepfire a=deepfire This adds the `locli` log analysis tool to `nix/workbench`, and integrates it. Co-authored-by: Kosyrev Serge <serge.kosyrev@iohk.io>
- Loading branch information
Showing
28 changed files
with
2,820 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
usage_analyse() { | ||
usage "analyse" "Analyse cluster runs" <<EOF | ||
block-propagation RUN-NAME | ||
Block propagation analysis for the entire cluster | ||
machine-timeline RUN-NAME MACH-NAME | ||
Produce a general performance timeline for MACH-NAME | ||
EOF | ||
} | ||
|
||
analyse() { | ||
local op=${1:-$(usage_analyse)}; shift | ||
|
||
case "$op" in | ||
block-propagation | bp ) | ||
local usage="USAGE: wb analyse $op [RUN-NAME=current]" | ||
local name=${1:-current} | ||
local dir=$(run get "$name") | ||
local adir=$dir/analysis | ||
|
||
mkdir -p "$adir" | ||
|
||
## 0. subset what we care about into the keyfile | ||
local keyfile=$adir/substring-keys | ||
locli analyse substring-keys | grep -v 'Temporary modify' > "$keyfile" | ||
cat >>"$keyfile" <<EOF | ||
TraceForgedBlock | ||
AddedToCurrentChain | ||
TraceChainSyncServerReadBlocked.AddBlock | ||
TraceChainSyncServerRead.AddBlock | ||
TraceBlockFetchServerSendBlock | ||
TraceDownloadedHeader | ||
CompletedBlockFetch | ||
EOF | ||
## 1. enumerate logs, filter by keyfile & consolidate | ||
local logdirs=("$dir"/node-*/) | ||
|
||
msg "filtering logs in: $dir/node-* " | ||
local jq_args=( | ||
--sort-keys | ||
--compact-output | ||
$(wb backend lostream-fixup-jqargs "$dir") | ||
' delpaths([["app"],["env"],["loc"],["msg"],["ns"],["sev"]]) | ||
'"$(wb backend lostream-fixup-jqexpr)" | ||
) | ||
for d in "${logdirs[@]}" | ||
do ## TODO: supervisor-specific logfile layout | ||
grep -hFf "$keyfile" $(ls "$d"/stdout* | tac) | jq "${jq_args[@]}" > \ | ||
"$adir"/logs-$(basename "$d").flt.json & | ||
done | ||
wait | ||
|
||
msg "log sizes: (files: $(ls "$adir"/*.flt.json | wc -l), lines: $(cat "$adir"/*.flt.json | wc -l))" | ||
|
||
msg "analysing.." | ||
local locli_args=( | ||
--genesis "$dir"/genesis/genesis.json | ||
--run-metafile "$dir"/meta.json | ||
## -> | ||
# --logobjects-json "$adir"/logs-cluster.logobjects.json | ||
--analysis-json "$adir"/block-event-stream.json | ||
) | ||
|
||
locli 'analyse' 'block-propagation' \ | ||
"${locli_args[@]}" "$adir"/*.flt.json;; | ||
|
||
machine-timeline | machine | mt ) | ||
local usage="USAGE: wb analyse $op [RUN-NAME=current] [MACH-NAME=node-1]" | ||
local name=${1:-current} | ||
local mach=${2:-node-1} | ||
local dir=$(run get "$name") | ||
local adir=$dir/analysis | ||
|
||
mkdir -p "$adir" | ||
|
||
## 0. subset what we care about into the keyfile | ||
local keyfile=$adir/substring-keys | ||
locli analyse substring-keys | grep -v 'Temporary modify' > "$keyfile" | ||
|
||
## 1. enumerate logs, filter by keyfile & consolidate | ||
local logs=("$dir"/$mach/stdout) consolidated="$adir"/logs-$mach.json | ||
grep -hFf "$keyfile" "${logs[@]}" > "$consolidated" | ||
msg "analysing logs of: $mach (lines: $(wc -l "$consolidated"))" | ||
|
||
local locli_args=( | ||
--genesis "$dir"/genesis/genesis.json | ||
--run-metafile "$dir"/meta.json | ||
## -> | ||
--logobjects-json "$adir"/logs-$mach.logobjects.json | ||
--slotstats-json "$adir"/logs-$mach.slotstats.json | ||
--timeline-pretty "$adir"/logs-$mach.timeline.txt | ||
--stats-csv "$adir"/logs-$mach.stats.csv | ||
--analysis-json "$adir"/logs-$mach.analysis.json | ||
# --timeline-csv "$adir"/logs-$mach.timeline.csv | ||
# --cpu-spans-histogram-png "$adir"/logs-"$mach".cpu85-span-lens.png | ||
# --derived-vectors-0-csv "$adir"/logs-$mach".derived.1.csv | ||
# --derived-vectors-1-csv "$adir"/logs-$mach.derived.1.csv | ||
) | ||
|
||
locli 'analyse' 'machine-timeline' \ | ||
"${locli_args[@]}" "$consolidated";; | ||
|
||
* ) usage_analyse;; esac | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Copyright 2020 Input Output (Hong Kong) Ltd. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
import Cardano.Prelude hiding (option) | ||
|
||
import Control.Monad.Trans.Except.Exit (orDie) | ||
import qualified Options.Applicative as Opt | ||
|
||
import Cardano.Analysis.TopHandler | ||
import Cardano.Unlog.Parsers (opts, pref) | ||
import Cardano.Unlog.Run (renderCommandError, runCommand) | ||
|
||
|
||
main :: IO () | ||
main = toplevelExceptionHandler $ do | ||
|
||
co <- Opt.customExecParser pref opts | ||
|
||
orDie renderCommandError $ runCommand co |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
cabal-version: 2.4 | ||
|
||
name: locli | ||
version: 1.27 | ||
description: Cardano log analysis CLI. | ||
author: IOHK | ||
maintainer: operations@iohk.io | ||
license: Apache-2.0 | ||
license-files: | ||
NOTICE | ||
build-type: Simple | ||
|
||
library | ||
|
||
hs-source-dirs: src | ||
|
||
exposed-modules: Data.Accum | ||
Data.Distribution | ||
|
||
Cardano.Analysis.Profile | ||
Cardano.Analysis.TopHandler | ||
|
||
Cardano.Unlog.BlockProp | ||
Cardano.Unlog.Commands | ||
Cardano.Unlog.LogObject | ||
Cardano.Unlog.Parsers | ||
Cardano.Unlog.Resources | ||
Cardano.Unlog.Run | ||
Cardano.Unlog.SlotStats | ||
Cardano.Unlog.Summary | ||
Cardano.Unlog.Timeline | ||
|
||
other-modules: Paths_locli | ||
|
||
build-depends: base | ||
, aeson | ||
, aeson-pretty | ||
, async | ||
, attoparsec | ||
, attoparsec-iso8601 | ||
, bytestring | ||
, cardano-config | ||
, cardano-prelude | ||
, containers | ||
, directory | ||
, filepath | ||
, file-embed | ||
, gnuplot | ||
, Histogram | ||
, iohk-monitoring | ||
, optparse-applicative | ||
, optparse-generic | ||
, ouroboros-network | ||
, process | ||
, scientific | ||
, split | ||
, template-haskell | ||
, text | ||
, text-short | ||
, time | ||
, transformers | ||
, transformers-except | ||
, unordered-containers | ||
, utf8-string | ||
, vector | ||
|
||
default-language: Haskell2010 | ||
default-extensions: NoImplicitPrelude | ||
OverloadedStrings | ||
TupleSections | ||
|
||
ghc-options: -Wall | ||
-Wincomplete-record-updates | ||
-Wincomplete-uni-patterns | ||
-Wredundant-constraints | ||
-Wpartial-fields | ||
-Wcompat | ||
-Wno-all-missed-specialisations | ||
|
||
executable locli | ||
hs-source-dirs: app | ||
main-is: locli.hs | ||
default-language: Haskell2010 | ||
ghc-options: -threaded | ||
-Wall | ||
-rtsopts | ||
"-with-rtsopts=-T" | ||
build-depends: base | ||
, cardano-prelude | ||
, locli | ||
, optparse-applicative | ||
, text | ||
, text-short | ||
, transformers | ||
, transformers-except | ||
default-extensions: NoImplicitPrelude |
Oops, something went wrong.