bookkeeper
bookkeeper copied to clipboard
Bookkeeper CLI output format
QUESTION
Hello,
I'd like to change the format of the data returned by the CLI, particularly the Bookkeeper Shell.
Currently, everything goes through the logs.
Would it be possible to define a more usable format like the API with JSON output ?
Exemple :
-
currently :
- log4j2-bkcli.xml :
<Configuration status="warn" monitorInterval="10"> <Properties> <Property name="bookkeeper.cli.log.root.level">ERROR</Property> <Property name="bookkeeper.cli.log.root.appender">CONSOLE</Property> </Properties> <Appenders> <Console name="CONSOLE" target="SYSTEM_OUT"> <PatternLayout pattern="%m%n"/> </Console> </Appenders> <Loggers> <Root level="${sys:bookkeeper.cli.log.root.level}"> <AppenderRef ref="${sys:bookkeeper.cli.log.root.appender}"/> </Root> <Logger name="org.apache.bookkeeper.bookie.BookieShell" level="INFO"> <AppenderRef ref="CONSOLE"/> </Logger> <Logger name="org.apache.bookkeeper.tools.cli" level="INFO"> <AppenderRef ref="CONSOLE"/> </Logger> </Loggers> </Configuration>- command :
$ BOOKIE_LOG_CONF=conf/log4j2-bkcli.xml bin/bookkeeper shell listbookies -a- result :
All Bookies : BookieID:eda-pulsar-helm-chart-bookie-1.eda-pulsar-helm-chart-bookie.n-eda-d.svc.cluster.local:3181, IP:10.125.32.9, Port:3181, Hostname:eda-pulsar-helm-chart-bookie-1.eda-pulsar-helm-chart-bookie.n-eda-d.svc.cluster.local BookieID:eda-pulsar-helm-chart-bookie-0.eda-pulsar-helm-chart-bookie.n-eda-d.svc.cluster.local:3181, IP:10.125.33.90, Port:3181, Hostname:eda-pulsar-helm-chart-bookie-0.eda-pulsar-helm-chart-bookie.n-eda-d.svc.cluster.local BookieID:eda-pulsar-helm-chart-bookie-2.eda-pulsar-helm-chart-bookie.n-eda-d.svc.cluster.local:3181, IP:10.125.34.20, Port:3181, Hostname:eda-pulsar-helm-chart-bookie-2.eda-pulsar-helm-chart-bookie.n-eda-d.svc.cluster.local -
with output format :
- command :
$ BOOKIE_LOG_CONF=conf/log4j2-bkcli.xml bin/bookkeeper shell listbookies -a --output json- result :
{ "eda-pulsar-helm-chart-bookie-1.eda-pulsar-helm-chart-bookie.n-eda-d.svc.cluster.local:3181" : null, "eda-pulsar-helm-chart-bookie-0.eda-pulsar-helm-chart-bookie.n-eda-d.svc.cluster.local:3181" : null, "eda-pulsar-helm-chart-bookie-2.eda-pulsar-helm-chart-bookie.n-eda-d.svc.cluster.local:3181" : null }