grafana

package
v0.4.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2022 License: Apache-2.0 Imports: 15 Imported by: 10

Documentation

Index

Constants

View Source
const AddPromDatasource = "/api/datasources"
View Source
const DeletePromDatasource = "/api/datasources/%d"
View Source
const GetPromDatasource = "/api/datasources/%d"
View Source
const PromDatasource = "/api/datasources"
View Source
const UpdatePromDatasource = "/api/datasources/%d"

Variables

This section is empty.

Functions

func NewGrafanaHTTPReverseProxy

func NewGrafanaHTTPReverseProxy(serverAddr string, transport http.RoundTripper) func(writer http.ResponseWriter, request *http.Request)

Types

type BasicAuthPayload

type BasicAuthPayload struct {
	BasicAuthUser     string          `json:"basicAuthUser,omitempty"`
	BasicAuthPassword string          `json:"basicAuthPassword,omitempty"`
	SecureJsonData    *SecureJsonData `json:"secureJsonData,omitempty"`
	JsonData          *JsonData       `json:"jsonData,omitempty"`
}

type Config

type Config struct {
	Host      string `env:"GRAFANA_HOST" envDefault:"localhost"`
	Port      string `env:"GRAFANA_PORT" envDefault:"8090"`
	Namespace string `env:"GRAFANA_NAMESPACE" envDefault:"devtroncd"`
}

func GetConfig

func GetConfig() (*Config, error)

type CreateDatasourceRequest

type CreateDatasourceRequest struct {
	Name             string `json:"name"`
	Type             string `json:"type"`
	Url              string `json:"url"`
	Access           string `json:"access"`
	BasicAuth        bool   `json:"basicAuth"`
	BasicAuthPayload `json:",inline"`
}

type DatasourceResponse

type DatasourceResponse struct {
	Id      int    `json:"id"`
	Message string `json:"message"`
	Name    string `json:"name"`
}

type GetPrometheusDatasourceResponse

type GetPrometheusDatasourceResponse struct {
	Id                int              `json:"id"`
	OrgId             int              `json:"orgId"`
	Name              string           `json:"name"`
	Type              string           `json:"type"`
	TypeLogoUrl       string           `json:"typeLogoUrl"`
	Access            string           `json:"access"`
	Url               string           `json:"url"`
	Password          string           `json:"password"`
	User              string           `json:"user"`
	Database          string           `json:"database"`
	BasicAuth         bool             `json:"basicAuth"`
	BasicAuthUser     string           `json:"basicAuthUser"`
	BasicAuthPassword string           `json:"basicAuthPassword"`
	WithCredentials   bool             `json:"withCredentials"`
	IsDefault         bool             `json:"isDefault"`
	JsonData          JsonData         `json:"jsonData"`
	SecureJsonFields  SecureJsonFields `json:"secureJsonFields"`
	Version           *int             `json:"version"`
	ReadOnly          bool             `json:"readOnly"`
}

type GrafanaClient

type GrafanaClient interface {
	GetAllDatasource() ([]*GetPrometheusDatasourceResponse, error)
	CreateDatasource(createDatasourceRequest CreateDatasourceRequest) (*DatasourceResponse, error)
	GetDatasource(datasourceId int) (*GetPrometheusDatasourceResponse, error)
	UpdateDatasource(updateDatasourceRequest UpdateDatasourceRequest, datasourceId int) (*DatasourceResponse, error)
}

type GrafanaClientConfig

type GrafanaClientConfig struct {
	GrafanaUsername string `env:"GRAFANA_USERNAME" envDefault:"admin"`
	GrafanaPassword string `env:"GRAFANA_PASSWORD" envDefault:"prom-operator"`
	GrafanaOrgId    int    `env:"GRAFANA_ORG_ID" envDefault:"2"`
	DestinationURL  string `env:"GRAFANA_URL" envDefault:""`
}

func GetGrafanaClientConfig

func GetGrafanaClientConfig() (*GrafanaClientConfig, error)

type GrafanaClientImpl

type GrafanaClientImpl struct {
	// contains filtered or unexported fields
}

func NewGrafanaClientImpl

func NewGrafanaClientImpl(logger *zap.SugaredLogger, client *http.Client, config *GrafanaClientConfig, attributesService attributes.AttributesService) *GrafanaClientImpl

func (*GrafanaClientImpl) CreateDatasource

func (impl *GrafanaClientImpl) CreateDatasource(createDatasourceRequest CreateDatasourceRequest) (*DatasourceResponse, error)

func (*GrafanaClientImpl) GetAllDatasource

func (impl *GrafanaClientImpl) GetAllDatasource() ([]*GetPrometheusDatasourceResponse, error)

func (*GrafanaClientImpl) GetDatasource

func (impl *GrafanaClientImpl) GetDatasource(datasourceId int) (*GetPrometheusDatasourceResponse, error)

func (*GrafanaClientImpl) UpdateDatasource

func (impl *GrafanaClientImpl) UpdateDatasource(updateDatasourceRequest UpdateDatasourceRequest, datasourceId int) (*DatasourceResponse, error)

type JsonData

type JsonData struct {
	HttpMethod    string   `json:"httpMethod,omitempty"`
	KeepCookies   []string `json:"keepCookies,omitempty"`
	AuthType      string   `json:"authType,omitempty"`
	DefaultRegion string   `json:"defaultRegion,omitempty"`
	TlsAuth       bool     `json:"tlsAuth"`
}

type SecureJsonData

type SecureJsonData struct {
	BasicAuthPassword string `json:"basicAuthPassword,omitempty"`
	TlsClientCert     string `json:"tlsClientCert,omitempty"`
	TlsClientKey      string `json:"tlsClientKey,omitempty"`
}

type SecureJsonFields

type SecureJsonFields struct {
}

type StatusCode

type StatusCode int

func (StatusCode) IsSuccess

func (code StatusCode) IsSuccess() bool

type UpdateDatasourceRequest

type UpdateDatasourceRequest struct {
	Id                int              `json:"id"`
	OrgId             int              `json:"orgId"`
	Name              string           `json:"name"`
	Type              string           `json:"type"`
	TypeLogoUrl       string           `json:"typeLogoUrl"`
	Access            string           `json:"access"`
	Url               string           `json:"url"`
	Password          string           `json:"password"`
	User              string           `json:"user"`
	Database          string           `json:"database"`
	BasicAuth         bool             `json:"basicAuth"`
	BasicAuthUser     string           `json:"basicAuthUser"`
	BasicAuthPassword string           `json:"basicAuthPassword"`
	WithCredentials   bool             `json:"withCredentials"`
	IsDefault         bool             `json:"isDefault"`
	JsonData          JsonData         `json:"jsonData"`
	SecureJsonFields  SecureJsonFields `json:"secureJsonFields"`
	Version           *int             `json:"version"`
	ReadOnly          bool             `json:"readOnly"`
	BasicAuthPayload  `json:",inline"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL