A JFrog CLI plugin or standalone binary to show open-metrics formatted data in a terminal based graph.
This JFrog CLI plugin is for viewing JFrog products metrics in real time in a terminal.
To build the metrics-viewer binary
go build
To build the metrics-viewer binary for multiple operating systems and architectures (Mac, Linux and Windows)
./build-binary.sh
# Just run the tests
go test ./...
# Run the tests and create a coverage report
mkdir -p out && go test -coverprofile=out/coverage.out ./... && go tool cover -html=out/coverage.out
To build the metrics-viewer into a Docker image and use it
# Build the Docker image
docker build -t metrics-viewer:0.2.1 .
# Test the Docker image
docker run --rm metrics-viewer:0.2.1 --version
If you don't want to install the plugin from the JFrog CLI Plugins Registry, it needs to be built and installed manually.
Follow these steps to install and use this plugin with JFrog CLI.
- Make sure JFrog CLI is installed on you machine by running
jf
. If it is not installed, install it. - Create a directory named
plugins
under~/.jfrog/
if it does not exist already. - Clone this repository.
- CD into the root directory of the cloned project.
- Run
go build
to create the binary in the current directory. - Copy the binary into the
~/.jfrog/plugins
directory.
Installing the latest version:
jf plugin install metrics-viewer
Installing a specific version:
jf plugin install metrics-viewer@version
Uninstalling a plugin
jf plugin uninstall metrics-viewer
You can view Artifactory Metrics in various ways. To try it out, you can run Artifactory as Docker container.
- Start Artifactory as Docker container and enable its metrics
docker run --rm -d --name artifactory \
-p 8082:8082 \
-e JF_SHARED_METRICS_ENABLED=true \
-v $(pwd)/artifactory:/var/opt/jfrog/artifactory/ docker.bintray.io/jfrog/artifactory-oss
- Once Artifactory is up, you can see the metrics log file or REST API endpoint
# See the metrics log files
cat artifactory/log/artifactory-metrics.log
cat artifactory/log/metadata-metrics.log
# Get the metrics from Artifactory REST API
curl -s -uadmin:password http://localhost:8082/artifactory/api/v1/metrics
The metrics-viewer can be run as a JFrog CLI Plugin or directly as a binary
- Usage
jf metrics-viewer <command> [options]
- Commands: See available commands by just running the binary
jf metrics-viewer
jf metrics-viewer help
- Options: To see available options for each command, call it with the help
jf metrics-viewer help graph
jf metrics-viewer help print
- Usage
./metrics-viewer <command> [options]
- Commands: See available commands by just running the binary
./metrics-viewer
./metrics-viewer help
- Options: To see available options for each command, call it with the help
./metrics-viewer help graph
./metrics-viewer help print
- Using the metrics-viewer binary
# Use with the default Artifactory that is configured by the JFrog CLI
jf metrics-viewer graph
# Use with direct Artifactory metrics API URL
jf metrics-viewer graph --url http://localhost:8082/artifactory/api/v1/metrics --user admin --password password
# Use with direct Metadata metrics API URL (NOTE: must get an access token from Artifactory)
jf metrics-viewer graph --url http://localhost:8082/metadata/api/v1/metrics --token ${TOKEN}
# Print metrics of the default Artifactory that is configured by the JFrog CLI
jf metrics-viewer print
# Print metrics of the "art17" Artifactory with name matching the "app_" filter
jf metrics-viewer print --server-id art17 --filter 'app_.*'
# Print selected Artifactory metrics as CSV
jf metrics-viewer print --url http://localhost:8082/artifactory/api/v1/metrics --user admin --password password \
--format csv --metrics jfrt_runtime_heap_totalmemory_bytes,jfrt_db_connections_active_total
- Using the metrics-viewer binary
# Use with the default Artifactory that is configured by the JFrog CLI
./metrics-viewer graph
# Use with direct Artifactory metrics API URL
./metrics-viewer graph --url http://localhost:8082/artifactory/api/v1/metrics --user admin --password password
# Use with direct Metadata metrics API URL (NOTE: must get an access token from Artifactory)
./metrics-viewer graph --url http://localhost:8082/metadata/api/v1/metrics --token ${TOKEN}
# Print metrics of the default Artifactory that is configured by the JFrog CLI
./metrics-viewer print
# Print metrics of the "art17" Artifactory with name matching the "app_" filter
./metrics-viewer print --server-id art17 --filter 'app_.*'
# Print selected Artifactory metrics as CSV
./metrics-viewer print --url http://localhost:8082/artifactory/api/v1/metrics --user admin --password password \
--format csv --metrics jfrt_runtime_heap_totalmemory_bytes,jfrt_db_connections_active_total
- Using the Docker image
# Use with direct Artifactory metrics API URL
# NOTE: The server URL has to be accessible from within the Docker container
docker run --rm --name metrics-viewer metrics-viewer:0.1 \
graph --url http://artifactory-server/artifactory/api/v1/metrics --user admin --password password
# Print specific metrics as CSV
# NOTE: The Docker container needs to access the file system for the logs, so need to mount it into the container
docker run --rm --name metrics-viewer -v $(pwd)/artifactory:/artifactory metrics-viewer:0.1 \
print --file /artifactory/log/artifactory-metrics.log \
--format csv --metrics jfrt_runtime_heap_freememory_bytes,jfrt_runtime_heap_totalmemory_bytes
Once running, the viewer will show 3 main sections
- Left pane: List of available metrics
- Center pane: Graph of selected metrics
- Right pane: Selected metrics Max, Min and Current values
- Up/Down arrow keys: Move between available metrics
- Space/Enter: Select/Deselect metric to view
- Free text: Apply text filter on available metrics
- Ctrl+C: Close metrics-viewer
The release notes are available here.
A big THANK YOU to the real developers here for joining me for this idea!