Dynatrace API
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How can I fetch all Kubernetes events for the past month using the Dynatrace API

Arunkumarbnp
Helper

I’m trying to retrieve Kubernetes events from the last month using the Dynatrace API, but I can only get 20 events at a time. How can I fetch all events for the past month? api details: {{baseUrl}}/it_prod-dynatrace-environment-apac/v2/events?entitySelector=entityId(KUBERNETES_CLUSTER-0FB79669080C9DD5)&from=now-30d&to=now&pageSize=500

7 REPLIES 7

p_devulapalli
Leader

@Arunkumarbnp How are you querying the API? Does the initial response include nextPageKey ?

Phani Devulapalli

Hi @p_devulapalli 
Thanks for your response
I use this api in postman
 api details: {{baseUrl}}/it_prod-dynatrace-environment-apac/v2/events?entitySelector=entityId(KUBERNETES_CLUSTER-0FB79669080C9DD5)&from=now-30d&to=now&pageSize=500


I tried with nextpagekey, I got the below error

"path": "entitySelector",
                "message": "must not be used in combination with nextPageKey query parameter.",
                "parameterLocation": "QUERY",
                "location": null

 

                "path": "to",
                "message": "must not be used in combination with nextPageKey query parameter.",
                "parameterLocation": "QUERY",
                "location": null

                "path": "pageSize",
                "message": "must not be used in combination with nextPageKey query parameter.",
                "parameterLocation": "QUERY",
                "location": null

@Arunkumarbnp When using nextpagekey, you need to omit all other query parameters and just use nextpagekey in the request to get a response. 

Phani Devulapalli

@p_devulapalli 

Thanks for your reply, 

If an entity is not explicitly specified in the API request, will nextPageKey still fetch all events for hosts and Kubernetes clusters within the management zone? Or does it only return events for entities that are directly referenced in the query?
I need k8 events only

@Arunkumarbnp Yes, the nextPageKey would fetch the response from next page with the filters set in first response. You would see only events of the specific cluster set in your first query

Phani Devulapalli

@p_devulapalli 
Can you please share me the right api, I'll check and let you know if it works

Featured Posts