# Metrics

Report, query and display metrics from sfp server

* [`sfp metrics display`](#sfp-metrics-display)
* [`sfp metrics query`](#sfp-metrics-query)
* [`sfp metrics report`](#sfp-metrics-report)

## `sfp metrics display`

Display a summary of key metrics from the SFP server

```
USAGE
  $ sfp metrics display [--json] [-c build|deploy|validate|release|prepare|all] [-d <value>] [--repository <value>]
    [-e <value>] [-t <value>] [--sfp-server-url <value>] [--loglevel
    trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]

FLAGS
  -c, --category=<option>          [default: all] Metric category to display
                                   <options: build|deploy|validate|release|prepare|all>
  -d, --days=<value>               [default: 30] Number of days to query (default: 30)
  -e, --email=<value>              [env: SFP_SERVER_USER] Email address for authenticated user. Ignored if
                                   --application-token is provided.
  -t, --application-token=<value>  [env: SFP_SERVER_TOKEN] Application token for CI/CD authentication. Takes precedence
                                   over --email.
      --loglevel=<option>          [default: info] logging level for this command invocation
                                   <options: trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL>
      --repository=<value>         The repository identifier. E.g `owner/repo`
      --sfp-server-url=<value>     [env: SFP_SERVER_URL] URL of the SFP server. Can be set via environment variable
                                   `SFP_SERVER_URL` or config: sfp config:set server-url

GLOBAL FLAGS
  --json  Format output as json.

DESCRIPTION
  Display a summary of key metrics from the SFP server

EXAMPLES
  $ sfp metrics:display

  $ sfp metrics:display --category build

  $ sfp metrics:display --category deploy --days 7

  $ sfp metrics:display --category all --days 90
```

*See code:* [*src/commands/metrics/display.ts*](https://source.flxbl.io/flxbl/sfp-pro)

## `sfp metrics query`

Query metrics from the SFP server

```
USAGE
  $ sfp metrics query [--json] [-n <value> | -q <value> | -l <value>] [-r <value>] [--package <value>] [--org
    <value>] [--branch <value>] [--start <value>] [--end <value>] [--step <value>] [--repository <value>] [-e <value>]
    [-t <value>] [--sfp-server-url <value>] [--loglevel
    trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]

FLAGS
  -e, --email=<value>              [env: SFP_SERVER_USER] Email address for authenticated user. Ignored if
                                   --application-token is provided.
  -l, --label=<value>              Get distinct values for a label (e.g., __name__, package, org)
  -n, --name=<value>               Metric name to query (e.g., build.duration, package.created). Supports wildcards like
                                   "build.*"
  -q, --query=<value>              Raw MetricsQL/PromQL query expression for advanced queries
  -r, --range=<value>              [default: 1h] Time range to query (default: 1h). Options: 5m, 15m, 30m, 1h, 3h, 6h,
                                   12h, 24h, 2d, 7d, 30d
  -t, --application-token=<value>  [env: SFP_SERVER_TOKEN] Application token for CI/CD authentication. Takes precedence
                                   over --email.
      --branch=<value>             Filter by branch name (used with --name)
      --end=<value>                Range end (RFC3339 or unix seconds). Overrides --range.
      --loglevel=<option>          [default: info] logging level for this command invocation
                                   <options: trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL>
      --org=<value>                Filter by target org (used with --name)
      --package=<value>            Filter by package name (used with --name)
      --repository=<value>         The repository identifier. E.g `owner/repo`
      --sfp-server-url=<value>     [env: SFP_SERVER_URL] URL of the SFP server. Can be set via environment variable
                                   `SFP_SERVER_URL` or config: sfp config:set server-url
      --start=<value>              Range start (RFC3339 or unix seconds). Overrides --range.
      --step=<value>               Step/resolution for range queries (e.g., 30s, 1m, 1h)

GLOBAL FLAGS
  --json  Format output as json.

DESCRIPTION
  Query metrics from the SFP server

EXAMPLES
  $ sfp metrics:query -n build.duration

  $ sfp metrics:query -n "build.*" --range 1h

  $ sfp metrics:query -n package.created --package salespkg --range 24h

  $ sfp metrics:query -q "sum(sfpowerscripts_build_completed)" --start 2024-01-01T00:00:00Z --end 2024-01-02T00:00:00Z --step 1h

  $ sfp metrics:query --label __name__
```

*See code:* [*src/commands/metrics/query.ts*](https://source.flxbl.io/flxbl/sfp-pro)

## `sfp metrics report`

Report a custom metric to any sfp supported metric provider

```
USAGE
  $ sfp metrics report -m <value> -t gauge|counter|timer [--json] [-v <value>] [-g <value>] [--repository <value>]
    [-e <value>] [-t <value>] [--sfp-server-url <value>] [--loglevel
    trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]

FLAGS
  -e, --email=<value>              [env: SFP_SERVER_USER] Email address for authenticated user. Ignored if
                                   --application-token is provided.
  -g, --tags=<value>               tags for metric (JSON format)
  -m, --metric=<value>             (required) metrics to publish
  -t, --application-token=<value>  [env: SFP_SERVER_TOKEN] Application token for CI/CD authentication. Takes precedence
                                   over --email.
  -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>
      --repository=<value>         The repository identifier. E.g `owner/repo`
      --sfp-server-url=<value>     [env: SFP_SERVER_URL] URL of the SFP server. Can be set via environment variable
                                   `SFP_SERVER_URL` or config: sfp config:set server-url

GLOBAL FLAGS
  --json  Format output as json.

DESCRIPTION
  Report a custom metric to any sfp supported metric provider

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

  $ sfp metrics:report -m build.duration -t timer -v 12000 --sfp-server-url http://localhost:3029 -e dev@flxbl.io
```

*See code:* [*src/commands/metrics/report.ts*](https://source.flxbl.io/flxbl/sfp-pro)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.flxbl.io/flxbl/sfp/sfp-community/cli-reference-v50-and-below/advanced/metrics.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
