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

Synthetic monitor for graphql

marcos_quintani
Newcomer

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?

3 REPLIES 3

Babar_Qayyum
DynaMight Guru
DynaMight Guru

Hello @MARCOS Q.

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

https://community.dynatrace.com/questions/240899/how-to-implement-dynatrace-one-agent-for-graphql-m....

Regards,

Babar

marcos_quintani
Newcomer

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

@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

Featured Posts