Synthetic monitoring API for k6s script

Hello everyone,

Has anyone successfully pushed a scripted monitor via API? I have done this for API endpoint monitors like HTTP, etc. (https://github.com/grafana/synthetic-monitoring-api-go-client/blob/main/docs/API.md.), but not for scripted ones for k6s. Additionally, has anyone found a way to hardcode a proxy in k6s scripted monitors? I mean without using envirnoment variable

Thank you for your assistance.

Hi @adrienhaddad,

Welcome to our community forums! :tada:

Has anyone successfully pushed a scripted monitor via API? I have done this for API endpoint monitors like HTTP, etc. (https://github.com/grafana/synthetic-monitoring-api-go-client/blob/main/docs/API.md.), but not for scripted ones for k6s

Could you please share the details about what are the error you’re getting, and/or an anonymized version of the payload/you’re using/sending to try to create a scripted check, please?

Additionally, has anyone found a way to hardcode a proxy in k6s scripted monitors? I mean without using environment variable.

I’m sorry, but I don’t fully get what you’re trying to achieve. Could you explain how would you like to set/use such proxy, and why using the environment variable doesn’t work? Perhaps you may point to the equivalent operation in k6 and, if not supported yet, we may work to add such to scripted checks, which use k6 under the hood.

Apologies for not being very resolution for now, but I hope I can help you more as soon as you bring further details :pray: Looking forward to them!

I think I understand from your answer that’s not a functionality developed already. Do you think it will in the future ? if is it ? is that foreseeable for 2025 ?
Thanks

Great approach to API monitoring! k6 makes it easy to simulate real traffic and check for performance or errors. Keep up the good work!

I don’t understand your question either. Let me extrapolate and feel free to correct me:

  • Q: “I have a k6 script to run and I want to deploy it to Synthetic programmatically” A: It’s possible. Our Terraform provider already allows it.
  • Q: “I want to monitor something using k6 scripts, how do I do ?” A: Refers to doc. The browser extension “Grafana k6 Browser Recorded” is a good solution to get started with Grafana Cloud
  • Q: “How to use a proxy in k6 script ?” A: Check this issue. There is a snippet using an extension for that.
  • My questions are not answered: can you re-explain your problem please ?
1 Like

Hi @adrienhaddad,

I think I understand from your answer that’s not a functionality developed already. Do you think it will in the future ? if is it ? is that foreseeable for 2025 ?

I reached the SM team, and here I have a bit more information, depending on how are you trying to create the scripted check:

  • If you’re using the go-client as a programmatic dependency, you should be able to call the AddCheck() method (this is what the Terraform provider does, you can probably find some code examples there).
  • As a CLI tool though, it does look like it only supports the following check types:
    • Ping
    • HTTP
    • DNS
    • TCP

If you’re looking for the latter, then I’d suggest you to create a new issue as a feature request in the client’s repository itself.

I hope that helps! :bowing_man:

Hi, here’s the clarification from my point of view of what I’m trying to achieve here.

  • Q: “I have a k6 script to run and I want to deploy it to Synthetic programmatically” A: It’s possible. Our Terraform provider already allows it. My Answer : I want to create k6 scripted monitor without doing manually. same as what’s possible here for HTTP synthetic-monitoring-api-go-client/docs/API.md at main · grafana/synthetic-monitoring-api-go-client · GitHub but for k6 scripted one.
  • Q: “How to use a proxy in k6 script ?” A: Check this issue. There is a snippet using an extension for that.
    My answer : I’ve seen this thread but We can’t add any extension or anything, as for example one k6 scripted monitor needs a certain proxy setting and another one needs another proxy setting, how do we solve that ? There’s should be a way to import a library in the k6 script to achieve it no ?