Skip to content

splunk/syntheticsclient

Repository files navigation

syntheticsclient

A Splunk Synthetics for Splunk Observability (Formerly Rigor) client for golang.

Installation

go get https://github.com/splunk/syntheticsclient.git

Important Note

V2 client is used to make API calls and CRUD operations to the Splunk Observability Synthetics endpoints (E.G. API Tests)

Deprecated V1 Client is used to make the API calls for the Splunk Synthetics (Formerly Rigor) public API.

Example Usages

package main

import (
	"fmt"
	"os"
	"encoding/json"
	sc2 "github.com/splunk/syntheticsclient/v2/syntheticsclientv2"
)

func main() {
	//Expects a token is available from the API_ACCESS_TOKEN environment variable
	//Expects a realm (e.g. us1) is available from REALM environment variable
	token := os.Getenv("API_ACCESS_TOKEN")
	realm := os.Getenv("REALM")

	//Create your client with the token
	c := sc2.NewClient(token, realm)

	//Take your ugly (but valid) JSON string as bytes and unmarshal into a CreateHttpCheckV2 struct
	jsonData := []byte(`{"test":{"name":"http-test","type":"http","url":"https://www.splunk.com","locationIds":["aws-us-east-1"],"frequency":10,"schedulingStrategy":"round_robin","active":true,"requestMethod":"GET","body":null,"headers":[{"name":"boop","value":"beep"}]}}`)
	var httpCheckDetail sc2.HttpCheckV2Input
	err := json.Unmarshal(jsonData, &httpCheckDetail)
	if err != nil {
		fmt.Println(err)
	}

	//Use your converted JSON to make the request and print
	res, _, err := c.CreateHttpCheckV2(&httpCheckDetail)
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Println(res)
	}
}

API Documentation

API Docs are available here

Request Details

V2 methods return RequestDetails for debugging failed or unexpected API calls. Use RequestDetails.RequestBody when you need to inspect the outgoing request. This field is sanitized before it is returned and redacts API tokens, certificate content, passwords, and generic secret values.

RequestDetails.RawRequest is intentionally not populated by V2 public API calls because a raw http.Request can retain authorization headers or request body secrets.

Additional Information

This client is largely a copypasta mutation of the go-victor client for Splunk On-Call (formerly known as VictorOps).

Contributions

Contributions are welcome and encouraged!

Please see CONTRIBUTING.md for details on contributing to this repository.

Before your contribution can be accepted, you will be asked to sign our Splunk Contributor License Agreement (CLA).

To agree to the CLA and COC please comment these in separate individual messages on your PR:

CLA:

I have read the CLA Document and I hereby sign the CLA

Code of Conduct:

I have read the Code of Conduct and I hereby accept the Terms

About

Splunk Synthetics Golang Client

Resources

License

Code of conduct

Contributing

Stars

1 star

Watchers

4 watching

Forks

Packages

 
 
 

Contributors