5.9. 创建指标

使用 3scale toolbox 在 Developer Portal 中创建、更新、列出和删除指标。

使用以下步骤创建指标:

  • 您必须提供指标名称。
  • 要覆盖 system-name,请使用可选参数。
  • 如果存在相同名称的指标,您将看到错误消息。
  • 使用 --disabled 标志创建禁用的指标。

    • 默认情况下将 启用 它。
注意
  • 服务 位置参数是服务引用,可以是服务 ID 或 service system_name

    • toolbox 使用其中任一个。

以下命令创建指标:

3scale metric create [opts] <remote> <service> <metric-name>

在创建指标时请使用以下选项:

Options
       --description=<value>      Set a metric description
       --disabled                 Disable this metric in all application
                                  plans
    -o --output=<value>           Output format on stdout:
                                  one of json|yaml
    -t --system-name=<value>      Set the application plan system name
       --unit=<value>             Metric unit: default hit

Options for metric
    -c --config-file=<value>      3scale toolbox configuration file:
                                  defaults to $HOME/.3scalerc.yaml
    -h --help                     Print help for this command
    -k --insecure                 Proceed and operate even for server
                                  connections otherwise considered insecure
    -v --version                  Print the version of this command
       --verbose                  Verbose mode

5.9.1. 创建或更新指标

如果新的指标不存在,请使用以下步骤创建新指标,或更新现有指标:

  • 如果存在相同名称的指标,您将看到错误消息。
  • 使用 --disabled 标志更新禁用的指标。
  • 使用 --enabled 标志更新为 启用 的指标。
注意
  • 服务 位置参数是服务引用,可以是服务 ID 或 service system_name

    • toolbox 使用其中任一个。
  • 指标 位置参数是指标引用,可以是指标 ID 或指标 system_name

    • toolbox 使用其中任一个。

以下命令更新了指标:

3scale metric apply [opts] <remote> <service> <metric>

在更新指标时请使用以下选项:

Options
       --description=<value>      Set a metric description
       --disabled                 Disable this metric in all application
                                  plans
       --enabled                  Enable this metric in all application
                                  plans
    -n --name=<value>             This will set the metric name
       --unit=<value>             Metric unit: default hit
    -o --output=<value>           Output format on stdout:
                                  one of json|yaml

Options for metric
    -c --config-file=<value>      3scale toolbox configuration file:
                                  defaults to $HOME/.3scalerc.yaml
    -h --help                     Print help for this command
    -k --insecure                 Proceed and operate even for server
                                  connections otherwise considered insecure
    -v --version                  Print the version of this command
       --verbose                  Verbose mode

5.9.2. 列出指标

以下命令列出了指标:

3scale metric list [opts] <remote> <service>

在列出指标时请使用以下选项:

Options
    -o --output=<value>           Output format on stdout:
                                  one of json|yaml

Options for metric
    -c --config-file=<value>      3scale toolbox configuration file:
                                  defaults to $HOME/.3scalerc.yaml
    -h --help                     Print help for this command
    -k --insecure                 Proceed and operate even for server
                                  connections otherwise considered insecure
    -v --version                  Print the version of this command
       --verbose                  Verbose mode

5.9.3. 删除指标

以下命令删除指标:

3scale metric delete [opts] <remote> <service> <metric>

在删除指标时请使用以下选项:

Options for metric
    -c --config-file=<value>      3scale toolbox configuration file:
                                  defaults to $HOME/.3scalerc.yaml
    -h --help                     Print help for this command
    -k --insecure                 Proceed and operate even for server
                                  connections otherwise considered insecure
    -v --version                  Print the version of this command
       --verbose                  Verbose mode