You can perform configuration and monitoring tasks for managed services. With OpenShift API Management you can manage network configurations, define policies, monitor API usage, and update notification settings.
Overview of rate limiting, alerting, and monitoring in OpenShift API Management
Red Hat OpenShift API Management provides a limited number of API calls. The API request hard limits are set as part of your Red Hat OpenShift API Management purchase.
You are alerted to ensure you do not exceed the set API usage hard limit. OpenShift API Management uses a tiered approach for alerting customers when the API usage is close to the hard limit, to ensure request calls are not rejected and service is not interrupted.
An email notification is sent to the email address provided during the OpenShift API Management installation. The email notification includes a link to the Grafana dashboard, which provides a visualization of your API usage.
A notification is sent in the following instances:
-
If API usage is between 80% and 90% for a period of 4 hours, a notificication is sent every 4 hours.
-
If API usage is between 90% and 95% for a period of 2 hours, a notification is sent every 2 hours.
-
If API usage is over 95% for a period of 30 minutes, a notification is sent every 30 minutes.
OpenShift API Management offers you the flexibility to share rate limiting quotas across multiple environments. You can divide a purchased OpenShift API Management subscription level across multiple OpenShift Dedicated environments. For example, if a 10 Million API calls per day subscription level is selected, you can allocate 5 Million API calls per day to both a stage environment and a production environment. For more information on increasing your Red Hat OpenShift API Management subscription level, see the service definition.
Monitoring service capacity with Grafana
You can can monitor the service capacity and API usage of OpenShift API Management with Grafana. Access the Grafana dashboard from the OpenShift Dedicated console, to monitor the OpenShift API Management API rate limits for the following durations:
-
last minute
-
last 24 hours
In the dashboard, you can view, share, and inspect the data for the OpenShift API Management API requests.
-
Red Hat OpenShift API Management was added to your OpenShift Dedicated cluster.
-
Click the application launcher in OpenShift Dedicated.
-
Click API Managed Dashboards in the OpenShift Managed Services drop-down menu.
-
You are prompted to log in. Click Log in with OpenShift.
-
Enter the login credentials.
-
Click Allow selected permissions to authorize monitoring access.
-
In the Grafana console, click the Dashboards dropdown menu from the main menu to access the available dashboards and folders.
-
Click Manage.
-
Click redhat-rhoam-customer-monitoring-operator to open the folder.
-
Click Rate Limiting to access the monitoring data.
Alternatively, click Home to search for a dashboard by name.
Modifying the daily rate limit quota after installing the Red Hat OpenShift API Management add-on
When you exceed your daily rate limit, your Red Hat OpenShift API Management services are interrupted and API request calls are rejected. To ensure API usage does not exceed its daily limit, you can modify your daily rate limit quota.
You can change the active daily rate limit quota, previously selected during the installation of the Red Hat OpenShift API Management add-on, in the OpenShift Cluster Manager to optimize resource consumption. You must have the resources required for the modified daily rate limit, as outlined in the Red Hat OpenShift API Management service definition, to successfully update the quota.
Depending on the SKU specified during the purchase of the Red Hat OpenShift API Management service, you can choose from the following daily rate limit quotas:
-
100 Thousand Requests (Evaluation option in OpenShift Dedicated trial clusters)
-
1 Million Requests
-
5 Million Requests
-
10 Million Requests
-
20 Million Requests
-
50 Million Requests
-
Red Hat OpenShift API Management was added to your OpenShift Dedicated or OpenShift Service on AWS cluster.
-
Enter the following URL in a browser:
https://cloud.redhat.com
-
Log in to your Red Hat account.
-
Click OpenShift in the main menu. The OpenShift Cluster Manager console opens.
-
In the OpenShift Cluster Manager, click Clusters in the menu. A list of clusters in the console is displayed.
-
Select the cluster that you want to modify from the list of clusters.
-
In the selected cluster, click the Add-ons tab.
-
In the Red Hat OpenShift API Management add-on option, click the three dots in the top corner of the option.
-
Click Configure in the drop-down menu. The Configure API Management service dialog box is displayed.
-
In the Quota field, select a daily rate limit quota from the drop-down menu.
-
Click Update.
-
Click the application launcher in the OpenShift Dedicated console.
-
Click API Managed Dashboards in the OpenShift Managed Services drop-down menu.
-
You are prompted to log in. Click Log in with OpenShift.
-
Enter the login credentials.
-
Click Allow selected permissions to authorize monitoring access.
-
In the Grafana console, click Home to access the available dashboards and folders.
-
Click redhat-rhoam-customer-monitoring-operator to open the folder.
-
Click Rate Limiting to access the monitoring data. Your active daily rate limit quota is displayed below the usage graph.
Deploying a self-managed APIcast API gateway
APIcast is an NGINX based API gateway used to integrate your internal and external API services with the 3scale platform.
APIcast has two deployment modes:
-
Built-in
-
Self-managed
By default, OpenShift API Management includes a built-in APIcast. The built-in APIcast is pre-configured and ready to use out-of-the-box.
If you want to modify the APIcast configuration, you can deploy a self-managed APIcast.
The Public Base URL is the URL, you can use to make requests to an API protected by 3scale. It is the URL of the the specificed APIcast instance.
With the self-managed deployment options, you can choose your own Public Base URL on the domain name you are managing. This URL should be different from the URL of your API backend. APIcast only accepts calls to the hostname specified in the Public Base URL.
-
You are a member in the
dedicated-admins
group. -
You have installed the OpenShift command-line Interface (CLI), commonly known as
oc
.
-
Create a new APIcast instance:
-
Log in to OpenShift using the
oc login
command from the OpenShift client tools.oc login https://<OPENSHIFT-SERVER-IP>
You should see
Login successful.
in the output. -
Create a new namespace for the self-managed APIcast.
oc new-project selfmanaged-apicast
-
-
Import the image.
oc import-image 3scale-amp2/apicast-gateway-rhel8:<tag> --from=registry.redhat.io/3scale-amp2/apicast-gateway-rhel8:<tag> --confirm
-
Navigate to the catalog.
-
Find the image and view the available tags.
An example<tag>
name is3scale<version>
. Use the<tag>
name that corresponds with the 3scale version installed on the cluster. -
(Optional) If you receive an error message after attempting to import the image, troubleshoot with the following steps:
-
Create a secret with credentials to
registry.redhat.io
. Use the following command to create a new secret to reference your project:oc create secret docker-registry redhatio --docker-server=registry.redhat.io --docker-username=<username> --docker-password=<password> --docker-email=<email>
-
Replace
<username>
with your Docker username. -
Replace
<password>
with your Docker password. -
Replace
<email>
with the email associated with your Docker account.
-
-
Use the following command to list active secrets and credentials:
oc get secrets
-
Use the following command to configure the pull secret:
oc secrets link default redhatio --for=pull
-
-
-
In the terminal, clone the Example custom policy from the GitHub repository and navigate to the directory.
git clone git@github.com:3scale/apicast-example-policy.git cd apicast-example-policy
-
Configure the
openshift.yaml
fileapiVersion: v1 kind: Template metadata: name: "apicast-example-policy" message: "APIcast Example Policy" objects: - apiVersion: v1 kind: ImageStream metadata: annotations: labels: app: apicast name: apicast-policy - apiVersion: v1 kind: BuildConfig metadata: annotations: labels: app: apicast name: apicast-example-policy spec: output: to: kind: ImageStreamTag name: apicast-policy:example source: git: uri: https://github.com/3scale/apicast-example-policy.git ref: 'master' type: Git strategy: type: Source sourceStrategy: from: kind: ImageStreamTag namespace: selfmanaged-apicast name: apicast-gateway-rhel8:<tag> - apiVersion: v1 kind: BuildConfig metadata: annotations: labels: app: apicast name: apicast-custom-policies spec: nodeSelector: null output: to: kind: ImageStreamTag namespace: selfmanaged-apicast name: apicast-gateway-rhel8:<tag> postCommit: args: - '--test' - '--lazy' command: - bin/apicast resources: {} runPolicy: Serial source: images: - from: kind: ImageStreamTag name: 'apicast-policy:example' paths: # copy policy source code into the new image - destinationDir: policies sourcePath: /opt/app-root/policies/example # copy also installed dependencies to the policy folder, so they are vendored # - destinationDir: policies/example/0.1/resty/ # sourcePath: /opt/app-root/src/lua_modules/share/lua/5.1/resty/iputils.lua type: Dockerfile dockerfile: | FROM scratch COPY . src USER root strategy: dockerStrategy: from: kind: ImageStreamTag namespace: selfmanaged-apicast name: apicast-gateway-rhel8:<tag> type: Docker triggers: - type: ConfigChange - type: ImageChange parameters: - name: AMP_RELEASE required: false description: AMP Version (eg. 2.2.0-GA)
-
Create a new application for your APIcast gateway and start the deployment:
oc new-app -f openshift.yml --param AMP_RELEASE=2.8
You should see the following message in the output:
--> Deploying template "sm-apicast/apicast-example-policy" for "openshift.yml" to project sm-apicast apicast-example-policy --------- APIcast Example Policy * With parameters: * AMP_RELEASE= --> Creating resources ... imagestream.image.openshift.io "apicast-policy" created buildconfig.build.openshift.io "apicast-example-policy" created buildconfig.build.openshift.io "apicast-custom-policies" created --> Success Use 'oc start-build apicast-example-policy' to start a build. Build scheduled, use 'oc logs -f bc/apicast-custom-policies' to track its progress. Run 'oc status' to view your app.
-
Execute the custom policy builds.
oc start-build apicast-example-policy
-
Navigate to the OpenShift Dedicated console.
-
Use Operator Hub to install the Red Hat Integration - 3scale APIcast gateway operator for the namespace.
Do not use the community version. -
Generate the 3scale Admin Portal token.
-
Log in to the Red Hat 3scale API Management console.
-
Click Personal in 3scale console menu.
-
Click Tokens in the menu.
-
Click Add Access Token.
-
On the New Access Token page, enter the required information in the fields.
-
Click Create Access token.
-
-
Create an
adminportal-credentials
secret.oc create secret generic adminportal-credentials --from-literal=AdminPortalURL=https://<access-token>@<url-to-3scale-admin-portal>
-
Configure the service to use the self-managed APIcast instead of the built-in APIcast for API.
-
Navigate to the Products section of the 3scale Admin Portal. You can use the following command to navigate to Admin Portal route:
oc get routes --namespace redhat-rhoam-3scale | grep admin
-
In the Products section, click API → Integration → Settings → APIcast Self Managed.
-
Change the Staging Public Base URL. Replace
api-3scale-apicast-
withselfmanaged-
. -
Click Update Product.
-
Click API → Configuration → Promote to Staging and to Production.
-
-
Create a self-managed APIcast.
-
Navigate to the self-managed APIcast operator page.
-
Click Create an APIcast.
-
Use Edit Form to configure the APIcast.
-
Change Admin Portal Credentials Ref secret name to
adminportal-credentials
. -
Set Configuration Load Mode to boot.
-
Set Image to
image-registry.openshift-image-registry.svc:5000/selfmanaged-apicast/apicast-policy:example
The image registry URL depends on the namespace. -
Click Create.
-
-
Create a new route to use with the application you plan to create.
-
Navigate to the namespace of the self-managed APIcast in the OpenShift Dedicated web console.
-
Click Networking → Routes → Create Route.
-
Enter the requested information in the text fields:
-
The Hostname must match the Staging Public Base URL (without protocol, without port).
-
For Service, select the service of your APIcast.
-
The target port is 8080 → 8080.
-
Select the secure route, TLS termination: Edge.
-
Click Create.
-
-
-
Navigate to the
apicast-example-policy
GitHub repository to makecustom-policy
available in the 3scale Admin Portal. -
Execute the following command:
cat policies/example/0.1/apicast-policy.json
-
Navigate to the 3scale console.
-
Click Integration → Configuration to promote the APIcast.
-
Click ? to access the help feature.
-
Click 3scale API docs → APIcast Policy Registry Create
-
-
Enter the required information:
-
Enter the access token.
-
Use the name from the
apicast-policy.json
. -
Use the version from the
apicast-policy.json
. -
In the schema field, enter the
apicast-policy.json
content.
-
-
Click Send Request.
-
Navigate to the 3scale Admin Portal.
-
In the console menu, click API → Integration → Policies → Add Policy. The APIcast Example Policy is listed.
-
Navigate to 3scale Admin Portal.
-
Click API → Configuration.
-
Execute the command for the Staging Public Base URL with the user key.
-
You can access the command for the Staging Public Base URL with the user key in the 3scale Admin Portal:
-
In the console menu, click Integration.
-
Click Configuration.
-
Use the command in the Example curl for testing in the Staging APIcast section.
-
-
-
The Example curl for testing output should include the following, if the APIcast proxy set up is successful:
"HTTP HOST": https://echo-api.3scale.net