Chapter 1. Defining Your API (Methods And Metrics)

download PDF

To define your API on 3scale, navigate to [Your_API_service] > Integration > Methods & Metrics and add your methods and metrics.

Metrics lets you track the usage of your API in 3scale. Hits is the built-in metric, it exists in each API service and is used to track the hits made to your API. You can achieve finer granularity for the API usage tracking by defining Methods under the Hits metric. Reporting traffic to a method will increase counters for the method and for the Hits metric automatically. You can define separate methods for each endpoint of you API, or a combination of endpoint and HTTP method. See Mapping rules section to learn how to map the endpoints of your API to the methods defined here.

For measuring other, not hit-based usage of your API, you can define new Metrics and report the usage in different units. A unit can be anything meaningful: megabytes, CPU time, number of elements returned by the API etc.

Methods and metrics are also the scaffolding to package your API: each application plan lets you define different usage limits and pricing rules for each method and metric.

You will be able to see the the usage reported to metrics and methods in the Analytics section.

1.1. Manually add methods and metrics

  1. Navigate to [Your_API_name] > Integration > Methods & Metrics.

    New Method New Metric
  2. Click on New method.
  3. Specify the parameters:

    • Friendly name is a short description of the method, it appears in different sections of the 3scale admin portal. This name must be unique for the service.
    • System name is the name of the method which will be used to report the usage through 3scale Service Management API. It also must be unique, and it should only contain alphanumeric characters, underscore _, hyphen - and forward slash / without spaces. Other than that, you are free to decide how the system name will look like, it can be exactly the same as the endpoint ("/status"), or for example can include the method and the path ("GET_/status").
    • The Description field can be used for a more detailed description of the method, it is optional.

      New Method Details
  4. Finally, click on Create Method button.

You can later change the definition of the method. Just click on the method name (in the column Method), update the fields and click on Update Method.

Be very careful with changing the system name of the methods and metrics or deleting them! It may break your already deployed 3scale integration, if there are mapping rules poining to the previous system name of the method.

For creating a new metric, click on New metric and provide the required parameters. When specifying the unit, use singular noun (e.g. "hit"), as it will be pluralized automatically in the Analytics charts.

These new methods and metrics will be available in all your current and future plans. You can now edit limits and pricing rules for them on each plan going to [Your_API_service] > Applications > Application Plans > [plan_you_want_to_edit].

1.2. Import your methods and metrics automatically

If your API has a lot of endpoints, we offer two additional ways of automatically creating your methods and metrics on 3scale:

Red Hat logoGithubRedditYoutubeTwitter


Try, buy, & sell


About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.