diff --git a/.ci_env b/.ci_env index 52bc55d..8af21fb 100644 --- a/.ci_env +++ b/.ci_env @@ -1,2 +1,2 @@ -DOCKER_ORGANIZATION="kuro08" +DOCKER_ORGANIZATION="ghcr.io/keptn-sandbox" IMAGE="splunk-sli-provider" \ No newline at end of file diff --git a/main.go b/main.go index 80dedb6..1a0dd71 100644 --- a/main.go +++ b/main.go @@ -112,7 +112,7 @@ func ProcessKeptnCloudEvent(ctx context.Context, event cloudevents.Event) error * parseKeptnCloudEventPayload(event, eventData) * * See https://github.com/keptn/spec/blob/0.2.0-alpha/cloudevents.md for more details of Keptn Cloud Events and their payload - * Also, see https://github.com/kuro-jojo/ echo-service/blob/a90207bc119c0aca18368985c7bb80dea47309e9/pkg/events.go as an example how to create your own CloudEvents + * Also, see https://github.com/keptn-sandbox/echo-service/blob/a90207bc119c0aca18368985c7bb80dea47309e9/pkg/events.go as an example how to create your own CloudEvents **/ /** diff --git a/pkg/splunksdk/README b/pkg/splunksdk/README index daca320..93f199e 100644 --- a/pkg/splunksdk/README +++ b/pkg/splunksdk/README @@ -1,56 +1,58 @@ -# Splunk SDK for Go +# Splunk SDK for Go The Splunk Software Development Kit for Go contains functions designed to enable developers to communicate with Splunk Enterprise through the splunk API. :warning: This version is more focused on getting metrics from Splunk Enterprise. + ## Getting started with the Splunk SDK for Go ### Requirements + Here's what you need to get going with the Splunk Enterprise SDK for Go. -* Go 1.18+ - - The Splunk SDK for Go has been tested with Go version 1.18 to 1.20 +- Go 1.18+ + + The Splunk SDK for Go has been tested with Go version 1.18 to 1.20 + +- Spunk Enterprise 9.0.4 -* Spunk Enterprise 9.0.4 + The Splunk SDK has been tested with Splunk Enterprise 9.0.4 - The Splunk SDK has been tested with Splunk Enterprise 9.0.4 -If you haven't already installed Splunk Enterprise, download it [here](http://www.splunk.com/download). For more information, see the Splunk Enterprise Installation Manual. + If you haven't already installed Splunk Enterprise, download it [here](http://www.splunk.com/download). For more information, see the Splunk Enterprise Installation Manual. +### Install the SDK -### Install the SDK This sdk can be found as an external package. Use the following command to install the Splunk SDK for Go go get -u github.com/kuro-jojo/splunk-sdk-go -### Example [![Go Reference](https://pkg.go.dev/badge/github.com/kuro-jojo/splunk-sdk-go.svg)](https://pkg.go.dev/github.com/kuro-jojo/splunk-sdk-go) - +### Example [![Go Reference](https://pkg.go.dev/badge/github.com/keptn-sandbox/splunk-sli-provider.svg)](https://pkg.go.dev/github.com/keptn-sandbox/splunk-sli-provider) You'll need at first a Splunk enterprise instance running. If you don't have one, you can run a local instance with a docker image. -* For that you'll need *docker* to be installed -* Then run a local Splunk enterprise instance (check it on [docker](https://hub.docker.com/r/splunk/splunk)) : +- For that you'll need _docker_ to be installed +- Then run a local Splunk enterprise instance (check it on [docker](https://hub.docker.com/r/splunk/splunk)) : docker run -d -p 8000:8000 -e "SPLUNK_START_ARGS=--accept-license" -e "SPLUNK_PASSWORD=" --name splunk splunk/splunk:latest - - After the container starts up successfully and enters the "healthy" state, you should be able to access SplunkWeb at http://localhost:8000 with admin:\. + After the container starts up successfully and enters the "healthy" state, you should be able to access SplunkWeb at http://localhost:8000 with admin:\. #### Following are the different ways to connect to Splunk Enterprise > :warning: Avoid writing your sensitive information in your code in production. Use environment variables or a configuration file instead. **Using username and password** + ```go import ( - splunk "github.com/keptn-sandbox/splunk-sli-provider/pkg/splunksdk/client" + splunk "github.com/keptn-sandbox/keptn-splunk-sli-provider/pkg/splunksdk/client" ) ... splunkInstance := "localhost" // or your splunk instance IP splunkServerPort := "8089" // by default splunkUsername := "admin" - splunkPassword := "myComplexPassword" // + splunkPassword := "myComplexPassword" // client := splunk.NewBasicAuthenticatedClient( &http.Client{ Timeout: time.Duration(60) * time.Second, @@ -59,12 +61,14 @@ You'll need at first a Splunk enterprise instance running. If you don't have one splunkServerPort, splunkUsername, splunkPassword, - true, // if true : SSL verification disabled + true, // if true : SSL verification disabled ``` + **Using token authentication** + ```go import ( - splunk "github.com/keptn-sandbox/splunk-sli-provider/pkg/splunksdk/client" + splunk "github.com/keptn-sandbox/keptn-splunk-sli-provider/pkg/splunksdk/client" ) ... splunkInstance := "localhost" @@ -77,12 +81,14 @@ You'll need at first a Splunk enterprise instance running. If you don't have one splunkInstance, splunkServerPort, splunkToken, - true, // if true : SSL verification disabled + true, // if true : SSL verification disabled ``` + **Using authentication sessionKey** + ```go import ( - splunk "github.com/keptn-sandbox/splunk-sli-provider/pkg/splunksdk/client" + splunk "github.com/keptn-sandbox/keptn-splunk-sli-provider/pkg/splunksdk/client" ) ... splunkInstance := "localhost" @@ -95,16 +101,16 @@ You'll need at first a Splunk enterprise instance running. If you don't have one splunkInstance, splunkServerPort, splunkSessionKey, - true, // if true : SSL verification disabled + true, // if true : SSL verification disabled ``` -#### Create a new job +#### Create a new job ```go ... -import ( - splunk "github.com/keptn-sandbox/splunk-sli-provider/pkg/splunksdk/client" - job "github.com/keptn-sandbox/splunk-sli-provider/pkg/splunksdk/jobs" +import ( + splunk "github.com/keptn-sandbox/keptn-splunk-sli-provider/pkg/splunksdk/client" + job "github.com/keptn-sandbox/keptn-splunk-sli-provider/pkg/splunksdk/jobs" ... ) ... @@ -132,11 +138,12 @@ import ( ``` #### Retrieving the results of a job + ```go ... -import ( - splunk "github.com/keptn-sandbox/splunk-sli-provider/pkg/splunksdk/client" - job "github.com/keptn-sandbox/splunk-sli-provider/pkg/splunksdk/jobs" +import ( + splunk "github.com/keptn-sandbox/keptn-splunk-sli-provider/pkg/splunksdk/client" + job "github.com/keptn-sandbox/keptn-splunk-sli-provider/pkg/splunksdk/jobs" ... ) ... @@ -152,11 +159,12 @@ import ( ``` #### Getting metric from a job + ```go ... -import ( - splunk "github.com/keptn-sandbox/splunk-sli-provider/pkg/splunksdk/client" - job "github.com/keptn-sandbox/splunk-sli-provider/pkg/splunksdk/jobs" +import ( + splunk "github.com/keptn-sandbox/keptn-splunk-sli-provider/pkg/splunksdk/client" + job "github.com/keptn-sandbox/keptn-splunk-sli-provider/pkg/splunksdk/jobs" ... ) ...