Custom Metrics

sfp provides multiple ways to enhance your metrics with custom data:

  1. Report custom metrics using the metrics:report command

  2. Add organization-wide custom tags to all metrics (sfp-pro only)

sfp metrics report

Report a custom metric to any sfp supported metric provider

USAGE
  $ @flxbl-io/sfp metrics report -m <value> -t gauge|counter|timer [-v <value>] [-g <value>] [--loglevel
    trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]

FLAGS
  -g, --tags=<value>       tags for metric
  -m, --metric=<value>     (required) metrics to publish
  -t, --type=<option>      (required) type of metric
                           <options: gauge|counter|timer>
  -v, --value=<value>      value of metric
      --loglevel=<option>  [default: info] logging level for this command invocation
                           <options: trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL>

DESCRIPTION
  Report a custom metric to any sfp supported metric provider

EXAMPLES
  $ sfp metrics:report -m <metric> -t <type> -v <value>

Custom Tags Configuration

sfp-pro
sfp (community)

Availability

From

August 25

sfp-pro allows you to configure custom tags that will be automatically added to ALL metrics sent by sfp. This is useful for adding consistent organizational metadata without modifying individual commands.

Setting Custom Tags

Use the sfp config set command with the custom-tag.* prefix:

Viewing Custom Tags

To see all configured custom tags:

Removing Custom Tags

Scope of Custom Tags

Custom tags follow the standard sfp configuration hierarchy:

  • Global tags: Set without --scope local, applies to all projects

  • Project-specific tags: Set with --scope local, applies only to current project

  • Project tags override global tags when both are present

How Custom Tags Work

  1. Automatic Inclusion: Custom tags are automatically added to every metric sent by sfp

  2. Tag Precedence: Command-specific tags override custom tags if there's a conflict

  3. GitHub Integration: Repository tags are automatically added when running in GitHub Actions

  4. Backend Support: Works with all supported metrics backends (StatsD, DataDog, NewRelic, Splunk)

Example Workflow

Use Cases

Team Attribution

Track metrics by team for resource allocation and performance monitoring:

Multi-Environment Tracking

Differentiate metrics across environments:

Cost Center Tracking

Associate metrics with cost centers for chargeback:

Project Metadata

Add project-specific context:

Best Practices

  1. Establish Naming Conventions: Define standard tag names across your organization

  2. Use Hierarchical Tags: Organize tags logically (e.g., team, squad, project)

  3. Automate Tag Configuration: Set tags in CI/CD pipeline initialization

  4. Document Required Tags: Maintain a list of required tags for your organization

  5. Regular Audits: Periodically review and clean up unused tags

CI/CD Integration

Configure custom tags in your CI/CD pipeline:

GitHub Actions

Jenkins

Azure DevOps

Limitations

  • Custom tags are loaded once at command initialization

  • Tag values must be strings

  • Tag names should follow your metrics backend's naming conventions

  • Maximum number of tags depends on your metrics backend limitations

Note: Custom tags are only available in sfp-pro edition. Community edition users must add tags manually to each command or upgrade to sfp-pro.

Last updated