19 Jan 2021 12:33 PM
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?
Solved! Go to Solution.
19 Jan 2021 01:04 PM - last edited on 16 Oct 2023 03:08 PM by random_user
Hello @MARCOS Q.
Have a look at the below link for relevant information. It may help out.
Regards,
Babar
19 Jan 2021 02:48 PM
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:
{
"step" : "stepOne",
"variables" : {
"input" : {
"identifier" : "XXXXXXXXX"
}
},
"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"
}
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
13 Apr 2021 05:38 PM - edited 13 Apr 2021 05:40 PM
@marcos_quintani
I had a similar request where we needed to query graphql with keycloak authentication to get some information to ingest into Dynatrace. I ended up writing a python script running on an ActiveGate and sending the data into Dynatrace API. 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