Skip to content

Repository files navigation

syntheticsclient

Release CI Checks Build License

A Go client for the Splunk Observability Synthetics API.

Installation

go get github.com/splunk/syntheticsclient/v3

Development

The supported Go baseline for main is the version pinned in .go-version (currently Go 1.26.7). Local tooling and CI both resolve their Go toolchain from that file.

Before opening a pull request, run the same checks CI runs:

make fmtcheck     # gofmt -l, fails on formatting drift
make vet          # go vet ./...
make lint         # golangci-lint v2.12.2, requires golangci-lint on PATH
make test-cover   # go test ./... with coverage
make test-race    # go test ./... -race
make govulncheck  # requires govulncheck on PATH
make actionlint   # lints .github/workflows, requires actionlint on PATH

golangci-lint, govulncheck, and actionlint are not vendored; install the versions CI pins with:

go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.12.2
go install golang.org/x/vuln/cmd/govulncheck@v1.7.0
go install github.com/rhysd/actionlint/cmd/actionlint@v1.7.12

Important Note

This client makes API calls and performs CRUD operations against the Splunk Observability Synthetics endpoints (e.g. API Tests).

It previously shipped an additional client for a legacy, now-decommissioned monitoring API. That package has been removed; only the Splunk Observability Synthetics client described below is supported.

Configuration

The client requires:

  • API_ACCESS_TOKEN — a Splunk Observability access token with permission to manage Synthetics tests.
  • REALM — the realm your organization is hosted in (e.g. us1).

Example Usages

package main

import (
	"fmt"
	"os"
	"encoding/json"
	sc2 "github.com/splunk/syntheticsclient/v3/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

Code of conduct

Contributing

Stars

1 star

Watchers

4 watching

Forks

Releases

Packages

Used by

Contributors

Languages