# API (Dashboard)

API Dashboard is used to show the statistics of every API of different sites, environments, and tenants. It can help you analyze the health status of APIs and find the root causes of API-related issues.

## Dashboard

**Login** -> **Utility and Admin** -> **Monitoring**, and you will see the dashboard of the sites which contains the API data that belong to your tenant. It shows many charts of the API from the beginning to now, such as total request count, success/fail rate, top fail APIs, etc. It can also support to change the time range on your own, or download reports of the API statistic data.

![API_Dashboard_1](image/monitor/API_Dashboard_1.png)

## Detail

Click on any site point in the dashboard map, and you will enter the detailed page, which shows more details of API than that of dashboard. The page contains a table of every data on the left side and three charts on the right side, showing the trend of API statistics. You can also change the statistic dimension by clicking on the table item or **X** in the top condition card. It supports four dimensions: site, environment, tenant, and API. Searching query and resorting the data (default: fail count and desc) are also fine.

* Site dimension

![API_Dashboard_2](image/monitor/API_Dashboard_2.png)

* Environment dimension

![API_Dashboard_3](image/monitor/API_Dashboard_3.png)

* Tenant dimension

![API_Dashboard_4](image/monitor/API_Dashboard_4.png)

* API dimension

![API_Dashboard_5](image/monitor/API_Dashboard_5.png)

### API Alerts

APIs have two major types of alerts:

- KeyAPI Alerts
- API Availability Alerts

Here, the definition of API failure is:

- status code >=500

#### KeyAPI Alerts

KeyAPI Alerts monitor KeyAPIs provided by users/customers/RBU/Tenant/PM… (only monitor KeyAPIs), with two thresholds:

- General: As shown below:

  ![image-20250408110607795](image/monitor/KeyAPIAlert_1.png)

- Sensitive: As shown below:

  ![image-20250408110626489](image/monitor/KeyAPIAlert_2.png)

##### Configuring KeyAPI Alerts

1. You can provide the following information to the SiteOps team, as shown in the example below:

| Environment Name                      | Tenant Name                                                                     | Micro Service Name                                                                                                                                                              | Method                                                                                                                                                                              | API path                                                                                      | API Description                |
| ------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | ------------------------------ |
| Separate Multiple environments commas | Take the field representing Tenant from Access Log as Tenant Name               | For old Accesslog standard: take appName from Access Log as Micro Service Name          For new Accesslog standard: take current_app_name from Access Log as Micro Service Name | For old Accesslog standard: take method from Access Log as Method     Http Method: GET POST PUT…          For new Accesslog standard: take request_method from Access Log as Method | Take path from Access Logs as API path                                                        |                           -     |
|                        -               | Use the field in ES Access Log representing "tenant" meaning, refer to "tenant" | Use the field in ES Access Log representing "service name" meaning,     refer to "appName" (old Accesslog standard), "current_app_name" (new Accesslog standard)                | Use the field in ES Access Log representing "method" meaning,     refer to "method" (old Accesslog standard), "request_method" (new Accesslog standard)                             |  -                                                                                             |  -                              |
| aws_jp_insuremo_prod                  | tsubaki                                                                         | tsubaki-bff                                                                                                                                                                     | POST                                                                                                                                                                                | [/tsubaki/1.0/bff/card/SMV10010](https://pttst-gw.insuremo.com/tsubaki/1.0/bff/card/SMV10010) | Card Info obtained             |
| aws_jp_insuremo_prod                  | tsubaki                                                                         | tsubaki-bff                                                                                                                                                                     | POST                                                                                                                                                                                | /tsubaki/1.0/bff/card/SMV10020                                                                | Insurance information obtained |

2. You can manually mark on the API Dashboard, as shown in the figure below:

   ![Mark KeyAPI](image/monitor/MarkKeyAPI_1.png)

3. After marking, you can see all marked KeyAPIs in the following way, as shown in the figure below:

   ![Key Api Alerts List](image/monitor/MarkKeyAPI_2.png)

#### API Availability Alerts

Even if you do not provide KeyAPI Alerts, we also provide basic API Availability Alerts (only for Prod environment).

This Alerts monitors all APIs under your tenant and alerts when the following conditions occur:

1. ErrorBudget: All API success rates < 99.5%.
2. BurnRate: All API success rates drop rapidly within a certain period.

The alert activation time is:

- When the tenant has officially gone live in Prod, specifically:
  - In CMDB, the tenant's Availability field is set to `enable`.
  - In CMDB, the Availability field for the tenant's Environment is set to `enable`.

### Troubleshooting

If you receive API Alerts, you can analyze and troubleshoot through **Monitor** -> **Log Dashboards**. For specific Log Dashboards usage, please refer to the corresponding document. Here are some brief steps for reference:

1. In Log Dashboards, switch to index: `apiaccesslog.*`.
2. Change the time range to: This Month.
3. In the query box, switch to `Lucene`, and enter, example for reference: `tenant: 88i AND (current_app_name: gateway OR current_app_name: api-gateway) AND status_code: 5??`.
4. After returning the results, analyze the results in detail to draw the following conclusions:
   1. The **time range** of the problem
   2. **API path**
   3. **`status_code`**
   4. **`trace_id`** (note one representative)
5. Then switch to index: `applog.*`.
6. In the query box, enter the corresponding `trace_id`.
7. View the specific:
   1. **Error Msg**
8. Draw conclusions.

## Support

<siteops@insuremo.com>
