# Synthetic monitor for graphql

**URL:** <https://community.dynatrace.com/t/synthetic-monitor-for-graphql/21233>\
**Category:** Synthetic Monitoring\
**Tags:** http-monitor, javascript, synthetic-monitoring\
**Created:** [January 19, 2021, 12:33pm UTC](https://community.dynatrace.com/t/synthetic-monitor-for-graphql/21233 "2021-01-19T12:33:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcos\_quintani](https://avatars.discourse-cdn.com/v4/letter/m/278dde/32.png) [@marcos\_quintani](https://community.dynatrace.com/u/marcos_quintani)\
**Post date:** [January 19, 2021, 12:33pm UTC](https://community.dynatrace.com/t/synthetic-monitor-for-graphql/21233/1 "2021-01-19T12:33:55Z")

</div>

Hello everyone, I will create a synthetic monitor for API based on graphql. Does Dynatrace support queries and / or mutation for this language in the post-scripting stage?

---

<div class="post-metadata">

**Author:** ![Babar\_Qayyum](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/babar_qayyum/32/13620_2.png) [@Babar\_Qayyum](https://community.dynatrace.com/u/Babar_Qayyum)\
**Post date:** [January 19, 2021, 1:04pm UTC](https://community.dynatrace.com/t/synthetic-monitor-for-graphql/21233/2 "2021-01-19T13:04:46Z")

</div>

Hello [@MARCOS Q.](https://community.dynatrace.com/users/43232/view.html)

Have a look at the below link for relevant information. It may help out.

> **[How to implement Dynatrace OneAgent for GraphQL Microservices running on...](https://community.dynatrace.com/t5/Container-platforms/How-to-implement-Dynatrace-OneAgent-for-GraphQL-Microservices/m-p/114072)**
>
> Hi Team, We are working on a POC to implement Dynatrace to monitor a application running on Red Hat OpenShift Container Platform. We know that DT OneAgent have capability of monitoring full stack OCP using smartscape Component. But here we are...

Regards,

Babar

---

<div class="post-metadata">

**Author:** ![marcos\_quintani](https://avatars.discourse-cdn.com/v4/letter/m/278dde/32.png) [@marcos\_quintani](https://community.dynatrace.com/u/marcos_quintani)\
**Post date:** [January 19, 2021, 2:48pm UTC](https://community.dynatrace.com/t/synthetic-monitor-for-graphql/21233/3 "2021-01-19T14:48:58Z")

</div>

Tank u @Babar Q. for answer my question, but I have other question about ‘_postProcessingScript_’ object. How to I add my query with variables of the authentication steps, a query exemple below:

```auto
{<br>    "step" : "stepOne",<br>    "variables" : {<br>        "input" : {<br>            "identifier" : "XXXXXXXXX"<br>        }<br>    },<br>    "query" : "query step($input: stepInputType) {\n  step(input: $input) {\n    result {\n      step\n       __typename\n    }\n    token\n    sessionId\n    __ typename\n  }\n}\n"<br>}

```

How to I capture a session or tokens and declare on the ‘_postProcessingScript_’? I have steps for capture this values?

I will capturing informations in the ‘stepOne’ and next transaction use this infos for follow flow.

Regards

---

<div class="post-metadata">

**Author:** ![michael\_joseph](https://avatars.discourse-cdn.com/v4/letter/m/e56c9b/32.png) [@michael\_joseph](https://community.dynatrace.com/u/michael_joseph)\
**Post date:** [April 13, 2021, 4:38pm UTC](https://community.dynatrace.com/t/synthetic-monitor-for-graphql/21233/4 "2021-04-13T16:38:46Z")

</div>

[@marcos\_quintani](https://community.dynatrace.com/user/31588)&nbsp;  
I had a similar request where we needed to query graphql with keycloak authentication to get some information to ingest into Dynatrace.&nbsp; I ended up writing a python script running on an ActiveGate and sending the data into Dynatrace API.&nbsp; Maybe this would help you out.

def query(self, \*\*kwargs):  
# Create device group within Dynatrace  
group1 = self.topology\_builder.create\_group(“GraphQL”, “GraphQL”)

# Configure client  
keycloak\_openid = KeycloakOpenID(server\_url=self.auth\_url,  
client\_id=self.clientid,  
realm\_name=self.tenant,  
client\_secret\_key=self.password)

# Get Token  
token = keycloak\_openid.token(self.username, self.password)  
tok = token[‘access\_token’]  
#logger.info(tok)

headers = {“Authorization”: "Bearer " + tok}  
#logger.info(headers)

query = “”"  
query {  
stats {  
summary  
tenantStats {  
alertQueue {  
size  
}  
ingestStats {  
ingestTime  
source  
}  
evalStats {  
last  
average  
}  
}  
}  
}  
“”"

request = requests.post(self.base\_url, json={‘query’: query}, headers=headers)

Regards,

Mike
