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

HTTP Synthetic Monitor API with sha256

H_THIM
Visitor

Hello .

Can someone help to rewrite a part of a python script in Dynatrace Synthetic using pre-script 

here is the code of my python script .

Spoiler
url ="https://endpointhost/parent/R000057/v1/sent/status"
api_key = "xaaaaxxxxxaaaaxxxxxaaaazzz"
secret = "ZxxAAUUaa"
ts = time.time()
sign = api_key+secret+str(timestamp)
shen256 = hashlib.sha256(sign.encode())
finalurl = url+"?api_key="+api_key+"&sig="+shen256.hexdigest()
headers = {"User-Agent":"Myapp/Python"}
response = requests.get(finalurl , headers=headers)

the difficulty is to rewrite the final url with  the Epoch  in combination with the key and secret .

i tryed many things but still not working .

any idea and help is welcome .

 

3 REPLIES 3

AntonPineiro
DynaMight Guru
DynaMight Guru

Hi,
I have just run and URL looks like this:

AntonPineiro_0-1746442941999.png

https://endpointhost/parent/R000057/v1/sent/status?api_key=xaaaaxxxxxaaaaxxxxxaaaazzz&sig=03fec1a1e92292b841fdd9c45add64421bfec456dbb871ccd2284cf04695f963

I have just changed "timestamp" for "ts" when you create "sign" variable:

sign = api_key+secret+str(ts)

Best regards

❤️ Emacs ❤️ Vim ❤️ Bash ❤️ Perl

Hello @AntonPineiro 

 

thanks for the quick reply.

Actually my python script is working well as expected what i want  is to do same thing in dynatrace on the HTTP monitor (in the pre-script) ..

what i want is to monitor the response of this request via synthetic monitor (HTTP) .

Hi,

You need to use JavaScript for this. This is another use case but maybe it would help you.

Best regards

❤️ Emacs ❤️ Vim ❤️ Bash ❤️ Perl

Featured Posts