# Monitoring state API for process groups (/api/v2/monitoringstate)

**URL:** <https://community.dynatrace.com/t/monitoring-state-api-for-process-groups-api-v2-monitoringstate/39319>\
**Category:** Dynatrace API\
**Tags:** documentation, dynatrace-api\
**Created:** [April 16, 2023, 3:18pm UTC](https://community.dynatrace.com/t/monitoring-state-api-for-process-groups-api-v2-monitoringstate/39319 "2023-04-16T15:18:27Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Julius\_Loman](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/julius_loman/32/51_2.png) [@Julius\_Loman](https://community.dynatrace.com/u/Julius_Loman)\
**Post date:** [April 16, 2023, 3:18pm UTC](https://community.dynatrace.com/t/monitoring-state-api-for-process-groups-api-v2-monitoringstate/39319/1 "2023-04-16T15:18:27Z")

</div>

Dynatrace [1.261 introduced new API /api/v2/monitoringstate](https://www.dynatrace.com/support/help/shortlink/changelog-api-sprint-261#ga-availability)&nbsp; for querying status of monitoring for process group instances. At first sight this looks as a replacement for legacy process group API v1.

It seems this API is not yet in the [documentation](https://www.dynatrace.com/support/help/shortlink/api-entities-v2)&nbsp;,&nbsp;[@jaroslaw\_orlows](https://community.dynatrace.com/user/21613)&nbsp;can you give a look?

I’d like to ask folks using the API already how can you use it on a larger scale?

I ran into two issues severly limiting usage of this API:

- API does not support pagination and the response is limited to 500 entities. How do you use it? Querying entities indivudually is not really an effective way of API usage.
- API does not seem to support filtering for monitoring state itself - typically I need to query processes where there an issue (like severity equals warning). There is just the healthState(UNHEALTHY) - which does not reflect the monitoring state.

---

<div class="post-metadata">

**Author:** ![ChadTurner](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/chadturner/32/161_2.png) [@ChadTurner](https://community.dynatrace.com/u/ChadTurner)\
**Post date:** [June 8, 2023, 4:42pm UTC](https://community.dynatrace.com/t/monitoring-state-api-for-process-groups-api-v2-monitoringstate/39319/2 "2023-06-08T16:42:57Z")

</div>

im right there with you on this&nbsp;[@Julius\_Loman](https://community.dynatrace.com/user/3364). Have you made any headway with this?

---

<div class="post-metadata">

**Author:** ![Julius\_Loman](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/julius_loman/32/51_2.png) [@Julius\_Loman](https://community.dynatrace.com/u/Julius_Loman)\
**Post date:** [June 8, 2023, 5:17pm UTC](https://community.dynatrace.com/t/monitoring-state-api-for-process-groups-api-v2-monitoringstate/39319/3 "2023-06-08T17:17:38Z")

</div>

[@ChadTurner](https://community.dynatrace.com/user/14877)&nbsp;no, there is no progress I’m aware of. In the current state is not useful for us, we are still using the legacy v1 smartscape API for process groups (mostly detecting processes requiring restarts).

---

<div class="post-metadata">

**Author:** ![ChadTurner](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/chadturner/32/161_2.png) [@ChadTurner](https://community.dynatrace.com/u/ChadTurner)\
**Post date:** [June 8, 2023, 5:27pm UTC](https://community.dynatrace.com/t/monitoring-state-api-for-process-groups-api-v2-monitoringstate/39319/4 "2023-06-08T17:27:18Z")

</div>

Yeah I tend to fall back on the Legacy methods even when they are “Deprecated” lol

---

<div class="post-metadata">

**Author:** ![Julius\_Loman](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/julius_loman/32/51_2.png) [@Julius\_Loman](https://community.dynatrace.com/u/Julius_Loman)\
**Post date:** [September 18, 2023, 9:18am UTC](https://community.dynatrace.com/t/monitoring-state-api-for-process-groups-api-v2-monitoringstate/39319/5 "2023-09-18T09:18:49Z")

</div>

Looks like some of my wishes sometimes make it to the product&nbsp;😁  
In 1.275 there is finally pagination supported as described in [release notes](https://www.dynatrace.com/support/help/shortlink/changelog-api-sprint-275). Still waiting for filtering on the monitoring states&nbsp;:dynaspin:

---

<div class="post-metadata">

**Author:** ![MichalC](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@MichalC](https://community.dynatrace.com/u/MichalC)\
**Post date:** [April 19, 2024, 1:58pm UTC](https://community.dynatrace.com/t/monitoring-state-api-for-process-groups-api-v2-monitoringstate/39319/6 "2024-04-19T13:58:26Z")

</div>

Hi,

I’d like to get a list of all process groups with status “restart\_required”. I supposed it should be entitySelector like this for monitoringState API:&nbsp;type(“PROCESS\_GROUP\_INSTANCE”),healthState(“HEALTHY”),state(“restart\_required”) but there is response:

{  
“error”: {  
“code”: 400,  
“message”: “Constraints violated.”,  
“constraintViolations”: [  
{  
“path”: “entitySelector”,  
“message”: “Scope: state. Cannot deserialize value: \“restart\_required\””,  
“parameterLocation”: “QUERY”,  
“location”: null  
}  
]  
}  
}

We need such option for filtering to replace depracated API:&nbsp;…/api/v1/entity/infrastructure/processes?restartRequired=true&includeDetails=true.

Please help.

Michal

---

<div class="post-metadata">

**Author:** ![Julius\_Loman](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/julius_loman/32/51_2.png) [@Julius\_Loman](https://community.dynatrace.com/u/Julius_Loman)\
**Post date:** [April 19, 2024, 9:03pm UTC](https://community.dynatrace.com/t/monitoring-state-api-for-process-groups-api-v2-monitoringstate/39319/7 "2024-04-19T21:03:22Z")

</div>

That’s what I mentioned above. That API does not allow filtering on the severity or state value. You can only query by entitySelector and then iterate the output, which is far from being effective.

---

<div class="post-metadata">

**Author:** ![Julius\_Loman](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/julius_loman/32/51_2.png) [@Julius\_Loman](https://community.dynatrace.com/u/Julius_Loman)\
**Post date:** [May 29, 2024, 1:01pm UTC](https://community.dynatrace.com/t/monitoring-state-api-for-process-groups-api-v2-monitoringstate/39319/8 "2024-05-29T13:01:52Z")

</div>

Hello [@florian\_AIgner](https://community.dynatrace.com/user/4189) or other Dynatraces responsible for this API.

There are still issues with using this API, please improve it:

- entitySelector does not allow **filtering on last seen time** , despite the PGI does have this property. It’s not flexible&nbsp; to loop through all process group (even non-deep monitored ones) which are inactive for years. There are no other options to specify the timerange.
- entitySelector does not allow **filtering on severity or injection state**
- **Response** should be optionally **enriched with other related entities and properties** - such as Process group display name, Host ID, Host name, and Management zones name, …
- Please **add this to the documentation**. This endpoint is not listed in&nbsp;[Monitored entities API — Dynatrace Docs](https://docs.dynatrace.com/docs/shortlink/api-entities-v2)&nbsp;or anywhere else in the documentation

---

<div class="post-metadata">

**Author:** ![MichalC](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@MichalC](https://community.dynatrace.com/u/MichalC)\
**Post date:** [June 5, 2024, 12:51pm UTC](https://community.dynatrace.com/t/monitoring-state-api-for-process-groups-api-v2-monitoringstate/39319/9 "2024-06-05T12:51:00Z")

</div>

Hi,

Dynatrace Product Managers please improve this API, we need improvements too.

---

<div class="post-metadata">

**Author:** ![kurejko](https://avatars.discourse-cdn.com/v4/letter/k/e8c25b/32.png) [@kurejko](https://community.dynatrace.com/u/kurejko)\
**Post date:** [July 23, 2024, 2:29pm UTC](https://community.dynatrace.com/t/monitoring-state-api-for-process-groups-api-v2-monitoringstate/39319/10 "2024-07-23T14:29:19Z")

</div>

Agree with Julius, some filtering and response enrichment would be very helpful here.

---

<div class="post-metadata">

**Author:** ![ItamarMM](https://avatars.discourse-cdn.com/v4/letter/i/a183cd/32.png) [@ItamarMM](https://community.dynatrace.com/u/ItamarMM)\
**Post date:** [August 8, 2024, 2:17pm UTC](https://community.dynatrace.com/t/monitoring-state-api-for-process-groups-api-v2-monitoringstate/39319/11 "2024-08-08T14:17:26Z")

</div>

Please, the situation is so absurd, I don’t think it is normal that we must have to do invididual calls over thousands of processes just to obtain a list of what we need to restart…

---

<div class="post-metadata">

**Author:** ![MichalC](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@MichalC](https://community.dynatrace.com/u/MichalC)\
**Post date:** [October 1, 2024, 11:37am UTC](https://community.dynatrace.com/t/monitoring-state-api-for-process-groups-api-v2-monitoringstate/39319/12 "2024-10-01T11:37:16Z")

</div>

Using this API we need to iterate through tousands of process instances at present to get a list PODs to restart. It’s far from green coding and it’s to slow to use it during our deployments. Dynatrace please improve it quickly.

---

<div class="post-metadata">

**Author:** ![HeadScratcher](https://avatars.discourse-cdn.com/v4/letter/h/85f322/32.png) [@HeadScratcher](https://community.dynatrace.com/u/HeadScratcher)\
**Post date:** [December 12, 2024, 3:30pm UTC](https://community.dynatrace.com/t/monitoring-state-api-for-process-groups-api-v2-monitoringstate/39319/13 "2024-12-12T15:30:13Z")

</div>

Also interested in using this API effectively…

---

<div class="post-metadata">

**Author:** ![lukegoyer](https://avatars.discourse-cdn.com/v4/letter/l/71e660/32.png) [@lukegoyer](https://community.dynatrace.com/u/lukegoyer)\
**Post date:** [June 19, 2025, 1:11pm UTC](https://community.dynatrace.com/t/monitoring-state-api-for-process-groups-api-v2-monitoringstate/39319/14 "2025-06-19T13:11:46Z")

</div>

I’m running into this issue currently across a number of k8s clusters. Is there a way to identify the entities with DQL currently? I’m thinking I could create a workflow to restart the applications.

---

<div class="post-metadata">

**Author:** ![jerry\_lobenstei](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@jerry\_lobenstei](https://community.dynatrace.com/u/jerry_lobenstei)\
**Post date:** [June 19, 2025, 4:43pm UTC](https://community.dynatrace.com/t/monitoring-state-api-for-process-groups-api-v2-monitoringstate/39319/15 "2025-06-19T16:43:23Z")

</div>

I run the API via a Notebook-(Dynatrace SaaS) that will pull the PGI STATE for all process or I can change to just the desired PGI’s.&nbsp; &nbsp;Import the Notebook, Accept and Run.

\* This function will run in the DYNATRACE JavaScript runtime via a Notebook.  
\* For information visit [App functions | Dynatrace Developer](https://dt-url.net/functions-help)

 ![jerry_lobenstei_0-1750351006232.png](https://global.discourse-cdn.com/dynatrace/original/2X/0/0979be7929b676883c45c8b91d15bed22415102e.png)  
[Code\_ Run API PGI State.json](https://community.dynatrace.com/uploads/short-url/eAiWq1Cz8jXV8B6dYRNxav1Ijcn.json) (82.8 KB)

---

<div class="post-metadata">

**Author:** ![wiwinleung](https://avatars.discourse-cdn.com/v4/letter/w/41988e/32.png) [@wiwinleung](https://community.dynatrace.com/u/wiwinleung)\
**Post date:** [October 16, 2025, 5:54am UTC](https://community.dynatrace.com/t/monitoring-state-api-for-process-groups-api-v2-monitoringstate/39319/16 "2025-10-16T05:54:50Z")

</div>

Hi&nbsp;[jerry\_lobenstei](https://community.dynatrace.com/user/133)

Thanks for your notebook and it is very useful.&nbsp;However, I run into a problem of only returning 1000 records regardless of how I increase the&nbsp;maxResultsRecords or other parameters.

Anyone has idea of increasing the records?

Many thanks!Wiwin

---

<div class="post-metadata">

**Author:** ![jerry\_lobenstei](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@jerry\_lobenstei](https://community.dynatrace.com/u/jerry_lobenstei)\
**Post date:** [October 16, 2025, 1:04pm UTC](https://community.dynatrace.com/t/monitoring-state-api-for-process-groups-api-v2-monitoringstate/39319/17 "2025-10-16T13:04:22Z")

</div>

- 
  - **Default Limit:** &nbsp;If no&nbsp;limit&nbsp;command is explicitly specified in a DQL query, Dynatrace applies a default limit of 1,000 records.&nbsp;This default limit is automatically appended as the last line of the query.
  - **Explicitly Setting the Limit:** &nbsp;You can explicitly define the maximum number of records to be returned by adding&nbsp;| limit \<number\>&nbsp;to your DQL query.&nbsp;For example:&nbsp;  
fetch logs  
| filter loglevel == “ERROR”  
| limit 5000

### Utilize options to limit the scanned amount of data

Particularly when dealing with logs, a large amount of data is ingested in short periods. Even with a narrow query time range, a query can fetch a considerable amount of data.

To stop reading data after a specified amount, use the&nbsp;scanLimitGBytes&nbsp;[fetch command](https://docs.dynatrace.com/docs/discover-dynatrace/platform/grail/dynatrace-query-language/commands)&nbsp;optional parameter.&nbsp; To scan a larger amount of data, also allowing timeframes to be set.

fetch logs, scanLimitGBytes:100fetch logs, from:-2h, scanLimitGBytes:100

---

<div class="post-metadata">

**Author:** ![Kekashri](https://avatars.discourse-cdn.com/v4/letter/k/ee7513/32.png) [@Kekashri](https://community.dynatrace.com/u/Kekashri)\
**Post date:** [December 19, 2025, 4:49pm UTC](https://community.dynatrace.com/t/monitoring-state-api-for-process-groups-api-v2-monitoringstate/39319/18 "2025-12-19T16:49:53Z")

</div>

Hi&nbsp;&nbsp;[jerry\_lobenstei](https://community.dynatrace.com/user/133)

Thanks for sharing your approach.

We have a similar use case where we want to set up alerts for all services that were previously active but are now in an inactive state due to some issue and require a pod restart.

I tried implementing this approach and modified the query by adding namespace and management zone filters. I also updated this field:  
const twentyMinutesAgo = new Date(now.getTime() - 72 \* 60 \* 60 \* 1000);

However, I am only seeing 14 records, whereas there should be more in the last 72 hours. Additionally, if I do not use the namespace filter, the data returned is only for a single namespace instead of all namespaces.

Could you please help me figure out what might be causing this issue?

```javascript
/*
* This function will run in the DYNATRACE JavaScript runtime.
* For information visit https://dt-url.net/functions-help
*/
import { monitoredEntitiesMonitoringStateClient } from "@dynatrace-sdk/client-classic-environment-v2";
import { queryExecutionClient } from "@dynatrace-sdk/client-query";

// ****Dynatrace API****
async function fetchAllMonitoringStates(pgID) {
  const pgID_string = `${pgID.map(id => `"${id}"`).join(",")}`;
  let nextPageKey = null;
  const monitoringStates = [];
  do {
    const params = nextPageKey
      ? { nextPageKey }
      : { entitySelector: `entityId(${pgID_string})`};
    const result = await monitoredEntitiesMonitoringStateClient.getStates(params);
    monitoringStates.push(...result.monitoringStates);
    nextPageKey = result.nextPageKey;
  } while (nextPageKey);
  return monitoringStates
}
export default async function () {
  const now = new Date();
  const twentyMinutesAgo = new Date(now.getTime() - 72 * 60 * 1000);
  const formatDate = (date) => date.toISOString();
  const $dt_timeframe_from = formatDate(twentyMinutesAgo);
  const $dt_timeframe_to = formatDate(now);

// ****DQL Query****
  const dqlQuery = `
    fetch dt.entity.process_group_instance
    | fieldsAdd host.id=belongs_to[dt.entity.host], pg_id=instance_of[dt.entity.process_group], cgi_id=(belongs_to[dt.entity.container_group_instance])
    | lookup [fetch dt.entity.host], sourceField:host.id, lookupField:id, fields:{host.name=entity.name, host.hostGroupName=hostGroupName}
    | lookup [fetch dt.entity.process_group], sourceField:pg_id, lookupField:id, fields:{process.name=entity.name}
    | lookup [fetch dt.entity.container_group_instance
          | fieldsAdd pod_id=belongs_to[dt.entity.cloud_application_instance], namespace_id=belongs_to[dt.entity.cloud_application_namespace], node_id=belongs_to[dt.entity.host]
          | lookup [fetch dt.entity.cloud_application_instance], sourceField:pod_id, lookupField:id, fields:{pod_name=entity.name}
          | lookup [fetch dt.entity.cloud_application_namespace], sourceField:namespace_id, lookupField:id, fields:{namespace=entity.name}
          | lookup [fetch dt.entity.host], sourceField:node_id, lookupField:id, fields:{node_name=entity.name}], sourceField:cgi_id, lookupField:id, fields:{pod_name, namespace, node_name}
    | fields managementZones, host.id, host.name, host.hostGroupName, process.name, pod_name, namespace, node_name, id
    | sort process.name desc
    | filter namespace == "test-v2"
    | filter host.hostGroupName == "TEST.PROD"
    // | limit 5000
  `;

// ****Execution Performance Limits****
// const queryExecution = await queryExecutionClient.queryExecute({ body: { query: dqlQuery } });
  const queryExecution = await queryExecutionClient.queryExecute({ body: {
    query: dqlQuery, 
    fetchTimeoutSeconds:5000,
    defalutScanLimitsGbytes: 50,
    maxResultsBytes: 1000000,
    maxResultsRecords: 3000000
} });
  let dqlResults = [];
  while (true) {
    const queryPollResult = await queryExecutionClient.queryPoll({ requestToken: queryExecution.requestToken });
    if (queryPollResult.state !== "RUNNING") {
      dqlResults = queryPollResult.result.records;
      break;
    }
  }
  let pgID = dqlResults.map(item => item.id);
  const processAllChunks = async () => {
    const allMonitoringStates = [];
    for (let i = 0; i < pgID.length; i += 50) {
      const chunk = pgID.slice(i, i + 50);
      const chunkStates = await fetchAllMonitoringStates(chunk);
      allMonitoringStates.push(...chunkStates);
    }
    return allMonitoringStates;
  };
  const monitoringStates = await processAllChunks();
  const mergedResults = dqlResults.map(dqlItem => {
    const match = monitoringStates.find(apiItem => apiItem.entityId === dqlItem.id);
    return match ? { ...dqlItem, severity: match.severity, state: match.state } : dqlItem;
  });
 const filteredResults = mergedResults.filter(item => 
  item.state && item.state.toLowerCase().includes("restart")
); return filteredResults;
}

```

---

<div class="post-metadata">

**Author:** ![gasperetta](https://avatars.discourse-cdn.com/v4/letter/g/ac8455/32.png) [@gasperetta](https://community.dynatrace.com/u/gasperetta)\
**Post date:** [February 25, 2026, 10:32am UTC](https://community.dynatrace.com/t/monitoring-state-api-for-process-groups-api-v2-monitoringstate/39319/19 "2026-02-25T10:32:57Z")

</div>

thank you so much for this.

Is possible filter for state, i needed only the state “restart\_required\_outdated\_agent\_injected”

thanks for reply
