[email protected]
Search…
Metrics and Dashboards
All about collecting metrics from sfpowerscripts
Metrics should be a key part of your DevOps process. It is through these metrics, one can drive continuous improvement of your delivery process. Almost all commands in sfpowerscripts, are instrumented with StatsD as well as Log Based Metrics.

Getting started with Metrics

Stats D

1
# Set STATSD Environment Variables for logging metrics about this build
2
export SFPOWERSCRIPTS_STATSD=true
3
export SFPOWERSCRIPTS_STATSD_HOST=172.23.95.52
4
export SFPOWERSCRIPTS_STATSD_PORT=8125 // Optional, defaults to 8125
5
export SFPOWERSCRIPTS_STATSD_PROTOCOL=UDP // Optional, defualts to UDP, Supports UDP/TCP
Copied!

Log Based Metrics

sfpowerscripts is also able to generate metrics in a log file. These metrics are written to .sfpowerscripts/metrics.log in your working directory. This log file after every run of a command could be send to a log aggregator for further analysis.
The JSON payload consist of the the following, name of the metric (metric), type of the metric such as count, guage or timers ( type ), timestamp (timestamp) and followed by tags pertaining to the particular metric (tags)
A sample metric is shown below
1
{"metric":"sfpowerscripts.build.scheduled.packages","type":"count","timestamp":1616475396815,"tags":{"package":"core-crm","type":"Unlocked","is_diffcheck_enabled":"true","is_dependency_validated":"true","pr_mode":"false"}
Copied!
One could write a parse this file, and then send each individual entries to a logging system that allows JSON based logging.

Native Datadog Integration

sfpowerscripts is also able to integrate into Datadog natively using HTTP/HTTPS integration. This feature allows one to directly post metrics to Datadog instance without using an intermittent StatsD server to aggregate metrics before reaching an analyzer.
To setup native DataDog integration, you need to set the following environment variables
1
# Set DATADOG Environment Variables for logging metrics natively to DataDog
2
export SFPOWERSCRIPTS_DATADOG=true
3
export SFPOWERSCRIPTS_DATADOG_HOST=app.datadoghq.com // Or equivalent datadog region
4
export SFPOWERSCRIPTS_DATADOG_API_KEY=<your api key> // Refer to datadog documentation
Copied!

Native NewRelic Integration

sfpowerscripts is also able to integrate into NewRelic natively using HTTP/HTTPS integration. Similar to native DataDog integration, this feature allows one to directly post metrics to NewRelic without using an intermittent StatsD server to aggregate metrics before reaching an analyzer.
1
# Set NEWRELIC Environment Variables for logging metrics natively to NewRelic
2
export SFPOWERSCRIPTS_NEWRELIC=true
3
export SFPOWERSCRIPTS_NEWRELIC_API_KEY=<your api key> // Refer to newrelic documentation to generate an NEWRELIC INGEST KEY
Copied!

Metrics available within sfpowerscripts

The following are the list of metrics that are captured.
METRIC
DESCRIPTION
TYPE
sfpowerscripts.deploy.failed
Number of times deploy command failed
COUNT
sfpowerscripts.deploy.duration
Time spent on executing deploy command
GAUGE
sfpowerscripts.deploy.scheduled
Number of times deployment was scheduled to run
COUNT
sfpowerscripts.deploy.packages.scheduled
Number of packages that were scheduled to be deployed by the deploy command
GAUGE
sfpowerscripts.deploy.succeeded
Number of succeeded deploy executions
COUNT
sfpowerscripts.deploy.succeeded.packages
Number of packages that were successfully deployed
GAUGE
sfpowerscripts.deploy.failed
Number of times deploy command failed to execute
COUNT
sfpowerscripts.deploy.failed.packages
Number and details of packages that failed to deploy
GAUGE
sfpowerscripts.build.scheduled
Number of times build was scheduled to run
COUNT
sfpowerscripts.build.duration
Time spent on executing build command
GAUGE
sfpowerscripts.build.scheduled.packages
Number of packages being scheduled to build
GAUGE
sfpowerscripts.build.succeeded.packages
Number of packages successfully built
GAUGE
sfpowerscripts.build.failed.packages
Number of packages failed to build
GAUGE
sfpowerscripts.validate.scheduled
Number of scheduled validations
COUNT
sfpowerscripts.validate.succeeded
Number of successful validations
COUNT
sfpowerscripts.validate.failed
Number of time validate failed to execute
COUNT
sfpowerscripts.validate.duration
Time spent on executing validate command
GAUGE
sfpowerscripts.validate.packages.scheduled
Number of packages scheduled for installation in a validation
GAUGE
sfpowerscripts.validate.packages.succeeded
Number of successful package installations in a validation
GAUGE
sfpowerscripts.validate.packages.failed
Number of failed package installations in a validation
GAUGE

Sample Dashboards