Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] [control plane] api activity statistics diagram #19

Closed
miyaflowercat opened this issue Oct 29, 2024 · 8 comments · Fixed by #137 or #140
Closed

[FEATURE] [control plane] api activity statistics diagram #19

miyaflowercat opened this issue Oct 29, 2024 · 8 comments · Fixed by #137 or #140
Assignees
Labels
new feature New feature or request
Milestone

Comments

@miyaflowercat
Copy link
Contributor

a/c:

  • User would be able to view the following statistics regarding api activity within selected time range for a specific data plane env(stage or production)
  • request trend, break down by status(success or error)
  • daily error breakdown by response status code
  • top 7 popular endpoints and calling numbers
  • all the data could be either for all buyers or filtered by specific buyer company
@miyaflowercat miyaflowercat added the new feature New feature or request label Oct 29, 2024
@miyaflowercat miyaflowercat assigned KsiBart and unassigned KsiBart Oct 29, 2024
KsiBart pushed a commit that referenced this issue Oct 29, 2024
* KRAKEN-76: standard API mapping

* fix error and code smell

* correct style
@miyaflowercat miyaflowercat added this to the 1.2.0 milestone Oct 30, 2024
@miyaflowercat
Copy link
Contributor Author

miyaflowercat commented Oct 30, 2024

Get API requests stats

url - /products/{productId}/envs/{env}/statistics/api-activity-requests?requestStartTime={date}&requestEndTime={date}
request

curl --location --request GET 'http://localhost:8001/products/mef.sonata/envs/2fd92244-a8d1-43fc-b76d-d87ffb0172f4/statistics/api-activity-requests?requestStartTime=2024-10-17T00%3A00%3A00%2B02%3A00&requestEndTime=2024-10-21T00%3A00%3A00%2B02%3A00' \
--header 'Authorization: Bearer XXX' 

response

{
    "code": 200,
    "message": "OK",
    "data": {
        "requestStatistics": [
            {
                "date": "2024-10-17",
                "success": 388,
                "error": 620
            },
            {
                "date": "2024-10-18",
                "success": 357,
                "error": 651
            },
            {
                "date": "2024-10-19",
                "success": 393,
                "error": 615
            }
        ]
    }
}

@miyaflowercat
Copy link
Contributor Author

miyaflowercat commented Oct 30, 2024

Get error statistics

url - /products/{productId}/envs/{env}/statistics/error-requests?requestStartTime={date}&requestEndTime={date}
request

curl --location --request GET 'http://localhost:8001/products/mef.sonata/envs/2fd92244-a8d1-43fc-b76d-d87ffb0172f4/statistics/error-requests?requestStartTime=2024-10-17T00%3A00%3A00%2B02%3A00&requestEndTime=2024-10-21T00%3A00%3A00%2B02%3A00' \
--header 'Authorization: Bearer XXX'

response

{
    "code": 200,
    "message": "OK",
    "data": {
        "errorBreakdowns": [
            {
                "date": "2024-10-17",
                "errors": {
                    "400": 237,
                    "401": 229,
                    "404": 24,
                    "500": 130
                }
            },
            {
                "date": "2024-10-18",
                "errors": {
                    "400": 228,
                    "401": 229,
                    "404": 24,
                    "500": 170
                }
            }
        ]
    }
}

@miyaflowercat
Copy link
Contributor Author

miyaflowercat commented Oct 30, 2024

Get most popular endpoints

url - /products/{productId}/envs/{env}/statistics/most-popular-endpoint?requestStartTime={date}&requestEndTime={date}
request

curl --location --request GET 'http://localhost:8001/products/mef.sonata/envs/2fd92244-a8d1-43fc-b76d-d87ffb0172f4/statistics/most-popular-endpoint?requestStartTime=2024-10-17T00%3A00%3A00%2B02%3A00&requestEndTime=2024-10-21T00%3A00%3A00%2B02%3A00' \
--header 'Authorization: Bearer XXX'

response

{
    "code": 200,
    "message": "OK",
    "data": {
        "endpointUsages": [
            {
                "method": "GET",
                "endpoint": "/mefApi/sonata/order/789",
                "usage": 459,
                "popularity": 11.38
            },
            {
                "method": "GET",
                "endpoint": "/mefApi/sonata/product/825",
                "usage": 306,
                "popularity": 7.58
            },
            {
                "method": "GET",
                "endpoint": "/mefApi/sonata/product/789",
                "usage": 306,
                "popularity": 7.58
            },
            {
                "method": "POST",
                "endpoint": "/mefApi/sonata/order/789",
                "usage": 288,
                "popularity": 7.14
            },
            {
                "method": "GET",
                "endpoint": "/mefApi/sonata/geographicAddressManagement/v7/geographicAddress/825",
                "usage": 255,
                "popularity": 6.32
            },
            {
                "method": "GET",
                "endpoint": "/mefApi/sonata/order/825",
                "usage": 204,
                "popularity": 5.05
            },
            {
                "method": "POST",
                "endpoint": "/mefApi/sonata/product/825",
                "usage": 192,
                "popularity": 4.76
            }
        ]
    }
}

@miyaflowercat
Copy link
Contributor Author

all BE API calls from FE failed with 400 bad request.Image

@jaroslawmalekcodete
Copy link
Contributor

Hi @KsiBart
the FE should use requestStartTime instead of startTime and requestEndTime instead of endTime.

example

curl --location --request GET 'https://kraken-portal-cn.dev.consolecore.cc/api/products/mef.sonata/envs/b2d775e5-44ad-43cb-8dd4-6fbe52585ec9/statistics/api-activity-requests?requestStartTime=2024-10-12T08%3A28%3A08%2B01%3A00&requestEndTime=2024-11-12T08%3A28%3A08%2B01%3A00' \
--header 'Authorization: Bearer  XXX'

response

{
    "code": 200,
    "message": "OK",
    "data": {
        "requestStatistics": [
            {
                "date": "2024-11-01",
                "error": 12
            },
            {
                "date": "2024-11-04",
                "error": 3
            },
            {
                "date": "2024-11-05",
                "error": 1
            },
            {
                "date": "2024-11-06",
                "success": 2
            },
            {
                "date": "2024-11-07",
                "success": 1,
                "error": 38
            },
            {
                "date": "2024-11-08",
                "success": 54,
                "error": 30
            },
            {
                "date": "2024-11-09",
                "success": 62,
                "error": 6
            },
            {
                "date": "2024-11-10",
                "success": 2,
                "error": 4
            },
            {
                "date": "2024-11-11",
                "success": 11,
                "error": 21
            },
            {
                "date": "2024-11-12",
                "success": 11,
                "error": 6
            }
        ]
    }
}

@miyaflowercat
Copy link
Contributor Author

miyaflowercat commented Nov 13, 2024

Image

  • The line should be continuous
  • by default it should show recent 7 days data

@miyaflowercat
Copy link
Contributor Author

BE need to handle the data without status code - put them into error group

@cheng0504
Copy link

pass
Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment