Splunk Observability Cloud

Synthetics API try_run CI/CD Integration

iduran
New Member

Hi everyone,

I'm new to Splunk Cloud, and trying to implement test runs for post deployment in our CI/CD pipelines. We have many Tests in Synthetics and want to use them after the deployments, so that we can understand everything went well.

My problem is that, I make an API call to  /tests/api/try_now   from Postman with json body (test) and it works perfectly, but when I make the same call with  CURL  it hangs. I used this documentation :  https://dev.splunk.com/observability/reference/api/synthetics_api_tests/latest#endpoint-createtrynow... 

I tried many versions of the test json, sometimes it works with only one resource in it, sometimes it works without validation. My request test json is created automatically from an existing test, so I don't want to change it.

What can be the problem that it works with Postman but not cURL? Any help is appreciated.

Regards,

ilker

Labels (1)
0 Karma

iduran
New Member

Thank you for the answers, but I cannot make curl work in my Windows machine, so created a PowerShell script instead, which works as it supposed to be. I'm also looking forward for the option to run a Test via just 1 API call, which obviously make the Post Deployment Checks for our CI/CD Pipeline easier. I also opened a ticket for the support and talking for that. Let's wait and see when Splunk can implement that to Observability API. Thanks for the answers, Best regards

0 Karma

bishida
Splunk Employee
Splunk Employee

Hi,
I think something to consider here is the intended use-case for "try now". It's designed to be a test editing validation step--not an on-demand call to run the test once to analyze results. Since you're working in a CI/CD pipeline, I'm thinking your use-case is probably the latter. I believe we have a feature on our roadmap that will better serve your use-case. You may want to ask your account rep for a roadmap call to discuss this feature with an engineer who can help determine if the upcoming feature meets your use-case.

0 Karma

iduran
New Member

Hi @livehybrid ,

Thanks for the reply. There's no return from the command actually. I tried -v and it doesn't show anything unusual, just waiting for the response from API. The curl command I use as this :  

curl --location 'https://api.eu0.signalfx.com/v2/synthetics/tests/api/try_now?locationId=aws-eu-central-1' \
--header 'Content-Type: application/json' \
--header 'X-SF-TOKEN: XXXXXXXXXXXXX' \
--data '{ "test": { "name": "DOCID Check - Deployment Copy", "active": false, "frequency": 5, "schedulingStrategy": "round_robin", "locationIds": [ "aws-eu-central-1" ], "automaticRetries": 0, "customProperties": [ { "key": "group", "value": "DOCID" } ], "deviceId": 1, "requests": [ { "configuration": { "name": "Get Auth token", "url": "https://AAAAAA.XXXXXX.com/api/v3/authentication", "requestMethod": "POST", "headers": { "Content-Type": "application/json" }, "body": "{\n \"userName\": \"{{custom.user_name}}\",\n \"password\": \"{{custom.user_password}}\"\n}" }, "setup": [ { "code": "{{env.prod_user}}", "name": "JavaScript run", "type": "javascript", "variable": "user_name" }, { "code": "{{env.prod_user_password}}", "name": "JavaScript run", "type": "javascript", "variable": "user_password" } ], "validations": [ { "name": "Extract from response body", "type": "extract_json", "source": "{{response.body}}", "variable": "session_token", "extractor": "$.token" }, { "name": "Assert response code equals 201", "type": "assert_numeric", "actual": "{{response.code}}", "expected": "201", "comparator": "equals" } ] }, { "configuration": { "name": "Search by DOCID", "url": "https://tttt.xxxxx.com/api/Search?search=docid==11111111111", "requestMethod": "GET", "headers": { "Authorization": "Bearer {{custom.session_token}}" }, "body": null }, "setup": [], "validations": [ { "name": "Extract from response body", "type": "extract_json", "source": "{{response.body}}", "variable": "tripreference", "extractor": "$.trips.tripReference" } ] } ] } }'

 

Some json files works if I empty validation or only 1 request. Also empty json returns 404 error with some comments. But I need to get the test first and send it back with some modification in bash scripting.

0 Karma

livehybrid
SplunkTrust
SplunkTrust

Hi @iduran 

Do you get any specific error back from Curl? Are you able to share the full curl command (redacted) ?

If you havent done already, you could try adding '-v' to the curl command to get a more verbose output.

🌟 Did this answer help you? If so, please consider:

  • Adding karma to show it was useful
  • Marking it as the solution if it resolved your issue
  • Commenting if you need any clarification

Your feedback encourages the volunteers in this community to continue contributing

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...