server

package
v2.0.0-beta.5 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2020 License: MIT Imports: 48 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Dir is prefix of the assets in the bindata
	Dir = "../ui/build"
	// Default is the default item to load if 404
	Default = "../ui/build/index.html"
	// DebugDir is the prefix of the assets in development mode
	DebugDir = "ui/build"
	// DebugDefault is the default item to load if 404
	DebugDefault = "ui/build/index.html"
	// DefaultContentType is the content-type to return for the Default file
	DefaultContentType = "text/html; charset=utf-8"
)
View Source
const (
	// DefaultWidth is used if not specified
	DefaultWidth = 4
	// DefaultHeight is used if not specified
	DefaultHeight = 4
)
View Source
const ChunkSize int = 512

ChunkSize is the number of bytes per chunked transfer-encoding

View Source
const (
	ErrNotFlusher = "Expected http.ResponseWriter to be an http.Flusher, but wasn't"
)
View Source
const (
	// JSONType the mimetype for a json request
	JSONType = "application/json"
)
View Source
const ServerContextKey = serverContextKey("server")

ServerContextKey is the key used to specify that the server is making the requet via context

View Source
const UserContextKey = userContextKey("user")

UserContextKey is the context key for retrieving the user off of context

Variables

This section is empty.

Functions

func AddQueryConfig

func AddQueryConfig(c *chronograf.DashboardCell)

AddQueryConfig updates a cell by converting InfluxQL into queryconfigs If influxql cannot be represented by a full query config, then, the query config's raw text is set to the command.

func AddQueryConfigs

func AddQueryConfigs(d chronograf.Dashboard) (newDash chronograf.Dashboard)

AddQueryConfigs updates all the celsl in the dashboard to have query config objects corresponding to their influxql queries.

func Asset

func Asset(string) ([]byte, error)

Asset returns an error stating no assets were included in the binary.

func Assets

func Assets(opts AssetsOpts) http.Handler

Assets creates a middleware that will serve a single page app.

func AuthorizedToken

func AuthorizedToken(auth oauth2.Authenticator, logger chronograf.Logger, next http.Handler) http.HandlerFunc

AuthorizedToken extracts the token and validates; if valid the next handler will be run. The principal will be sent to the next handler via the request's Context. It is up to the next handler to determine if the principal has access. On failure, will return http.StatusForbidden.

func AuthorizedUser

func AuthorizedUser(
	store DataStore,
	useAuth bool,
	role string,
	logger chronograf.Logger,
	next http.HandlerFunc,
) http.HandlerFunc

AuthorizedUser extracts the user name and provider from context. If the user and provider can be found on the context, we look up the user by their name and provider. If the user is found, we verify that the user has at at least the role supplied.

func CorrectWidthHeight

func CorrectWidthHeight(c *chronograf.DashboardCell)

CorrectWidthHeight changes the cell to have at least the minimum width and height

func DashboardDefaults

func DashboardDefaults(d chronograf.Dashboard) (newDash chronograf.Dashboard)

DashboardDefaults updates the dashboard with the default values if none are specified

func Error

func Error(w http.ResponseWriter, code int, msg string, logger chronograf.Logger)

Error writes an JSON message

func FlushingHandler

func FlushingHandler(next http.Handler) http.Handler

FlushingHandler may not actually do anything, but it was ostensibly implemented to flush response writers that can be flushed for the purposes in the comment above.

func HSTS

func HSTS(next http.Handler) http.Handler

HSTS add HTTP Strict Transport Security header with a max-age of two years Inspired from https://blog.bracebin.com/achieving-perfect-ssl-labs-score-with-go

func HasAuthorizedToken

func HasAuthorizedToken(auth oauth2.Authenticator, r *http.Request) (oauth2.Principal, error)

HasAuthorizedToken extracts the token from a request and validates it using the authenticator. It is used by routes that need access to the token to populate links request.

func HasCorrectAxes

func HasCorrectAxes(c *chronograf.DashboardCell) error

HasCorrectAxes verifies that only permitted axes exist within a DashboardCell

func HasCorrectColors

func HasCorrectColors(c *chronograf.DashboardCell) error

HasCorrectColors verifies that the format of each color is correct

func HasCorrectLegend

func HasCorrectLegend(c *chronograf.DashboardCell) error

HasCorrectLegend verifies that the format of the legend is correct

func Logger

func Logger(logger chronograf.Logger, next http.Handler) http.Handler

Logger is middleware that logs the request

func Logout

func Logout(nextURL, basepath string, routes AuthRoutes) http.HandlerFunc

Logout chooses the correct provider logout route and redirects to it

func MoveTimeShift

func MoveTimeShift(c *chronograf.DashboardCell)

MoveTimeShift moves TimeShift from the QueryConfig to the DashboardQuery

func NewMux

func NewMux(opts MuxOpts, service Service) http.Handler

NewMux attaches all the route handlers; handler returned servers chronograf.

func PathEscape

func PathEscape(str string) string

PathEscape escapes the string so it can be safely placed inside a URL path segment. Change to url.PathEscape for go 1.8

func RawStoreAccess

func RawStoreAccess(logger chronograf.Logger, next http.HandlerFunc) http.HandlerFunc

RawStoreAccess gives a super admin access to the data store without a facade.

func Redoc

func Redoc(swagger string) http.HandlerFunc

Redoc servers the swagger JSON using the redoc package.

func RouteMatchesPrincipal

func RouteMatchesPrincipal(
	store DataStore,
	useAuth bool,
	logger chronograf.Logger,
	next http.HandlerFunc,
) http.HandlerFunc

RouteMatchesPrincipal checks that the organization on context matches the organization in the route.

func Spec

func Spec() http.HandlerFunc

Spec servers the swagger.json file from bindata

func ToQueryConfig

func ToQueryConfig(query string) chronograf.QueryConfig

ToQueryConfig converts InfluxQL into queryconfigs If influxql cannot be represented by a full query config, then, the query config's raw text is set to the query.

func ValidDashboardCellRequest

func ValidDashboardCellRequest(c *chronograf.DashboardCell) error

ValidDashboardCellRequest verifies that the dashboard cells have a query and have the correct axes specified

func ValidDashboardRequest

func ValidDashboardRequest(d *chronograf.Dashboard, defaultOrgID string) error

ValidDashboardRequest verifies that the dashboard cells have a query

func ValidDatabaseRequest

func ValidDatabaseRequest(d *chronograf.Database) error

ValidDatabaseRequest checks if the database posted is valid

func ValidInfluxRequest

func ValidInfluxRequest(p chronograf.Query) error

ValidInfluxRequest checks if queries specify a command.

func ValidRetentionPolicyRequest

func ValidRetentionPolicyRequest(rp *chronograf.RetentionPolicy) error

ValidRetentionPolicyRequest checks if a retention policy is valid on POST

func ValidTemplateRequest

func ValidTemplateRequest(template *chronograf.Template) error

ValidTemplateRequest checks if the request sent to the server is the correct format.

func ValidateQueryConfig

func ValidateQueryConfig(q *chronograf.QueryConfig) error

ValidateQueryConfig checks any query config input

func Version

func Version(version string, h http.Handler) http.Handler

Version handler adds X-Chronograf-Version header to responses

Types

type AllRoutes

type AllRoutes struct {
	GetPrincipal func(r *http.Request) oauth2.Principal // GetPrincipal is used to retrieve the principal on http request.
	AuthRoutes   []AuthRoute                            // Location of all auth routes. If no auth, this can be empty.
	LogoutLink   string                                 // Location of the logout route for all auth routes. If no auth, this can be empty.
	StatusFeed   string                                 // External link to the JSON Feed for the News Feed on the client's Status Page
	CustomLinks  map[string]string                      // Custom external links for client's User menu, as passed in via CLI/ENV
	Logger       chronograf.Logger
}

AllRoutes is a handler that returns all links to resources in Chronograf server, as well as external links for the client to know about, such as for JSON feeds or custom side nav buttons. Optionally, routes for authentication can be returned.

func (*AllRoutes) ServeHTTP

func (a *AllRoutes) ServeHTTP(w http.ResponseWriter, r *http.Request)

serveHTTP returns all top level routes and external links within chronograf

type AssetsOpts

type AssetsOpts struct {
	// Develop when true serves assets from ui/build directory directly; false will use internal bindata.
	Develop bool
	// Logger will log the asset served
	Logger chronograf.Logger
}

AssetsOpts configures the asset middleware

type AuthRoute

type AuthRoute struct {
	Name     string `json:"name"`     // Name uniquely identifies the provider
	Label    string `json:"label"`    // Label is a user-facing string to present in the UI
	Login    string `json:"login"`    // Login is the route to the login redirect path
	Logout   string `json:"logout"`   // Logout is the route to the logout redirect path
	Callback string `json:"callback"` // Callback is the route the provider calls to exchange the code/state
}

AuthRoute are the routes for each type of OAuth2 provider

type AuthRoutes

type AuthRoutes []AuthRoute

AuthRoutes contains all OAuth2 provider routes.

func AuthAPI

func AuthAPI(opts MuxOpts, router chronograf.Router) (http.Handler, AuthRoutes)

AuthAPI adds the OAuth routes if auth is enabled.

func (*AuthRoutes) Lookup

func (r *AuthRoutes) Lookup(provider string) (AuthRoute, bool)

Lookup searches all the routes for a specific provider

type CustomLink struct {
	Name string `json:"name"`
	URL  string `json:"url"`
}

CustomLink is a handler that returns a custom link to be used in server's routes response, within ExternalLinks

func NewCustomLinks(links map[string]string) ([]CustomLink, error)

NewCustomLinks transforms `--custom-link` CLI flag data or `CUSTOM_LINKS` ENV var data into a data structure that the Chronograf client will expect

type DashboardBuilder

type DashboardBuilder interface {
	Build(chronograf.DashboardsStore) (*multistore.DashboardsStore, error)
}

DashboardBuilder is responsible for building dashboards

type DataStore

DataStore is collection of resources that are used by the Service Abstracting this into an interface was useful for isolated testing

type DirectStore

type DirectStore struct {
	SourcesStore            chronograf.SourcesStore
	ServersStore            chronograf.ServersStore
	LayoutsStore            chronograf.LayoutsStore
	UsersStore              chronograf.UsersStore
	DashboardsStore         chronograf.DashboardsStore
	MappingsStore           chronograf.MappingsStore
	OrganizationsStore      chronograf.OrganizationsStore
	ConfigStore             chronograf.ConfigStore
	OrganizationConfigStore chronograf.OrganizationConfigStore
}

Store implements the DataStore interface

func (*DirectStore) Config

Config returns the underlying ConfigStore.

func (*DirectStore) Dashboards

Dashboards returns a noop.DashboardsStore if the context has no organization specified and an organization.DashboardsStore otherwise.

func (*DirectStore) Layouts

Layouts returns all layouts in the underlying layouts store.

func (*DirectStore) Mappings

Mappings returns the underlying MappingsStore.

func (*DirectStore) OrganizationConfig

func (s *DirectStore) OrganizationConfig(ctx context.Context) chronograf.OrganizationConfigStore

OrganizationConfig returns a noop.OrganizationConfigStore if the context has no organization specified and an organization.OrganizationConfigStore otherwise.

func (*DirectStore) Organizations

Organizations returns the underlying OrganizationsStore.

func (*DirectStore) Servers

Servers returns a noop.ServersStore if the context has no organization specified and an organization.ServersStore otherwise.

func (*DirectStore) Sources

Sources returns a noop.SourcesStore if the context has no organization specified and an organization.SourcesStore otherwise.

func (*DirectStore) Users

Users returns a chronograf.UsersStore. If the context is a server context, then the underlying chronograf.UsersStore is returned. If there is an organization specified on context, then an organizations.UsersStore is returned. If niether are specified, a noop.UsersStore is returned.

type ErrorMessage

type ErrorMessage struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

ErrorMessage is the error response format for all service errors

type InfluxClient

type InfluxClient struct{}

InfluxClient returns a new client to connect to OSS or Enterprise

func (*InfluxClient) New

New creates a client to connect to OSS or enterprise

type KapacitorBuilder

type KapacitorBuilder interface {
	Build(chronograf.ServersStore) (*multistore.KapacitorStore, error)
}

KapacitorBuilder builds a KapacitorStore

type LayoutBuilder

type LayoutBuilder interface {
	Build(chronograf.LayoutsStore) (*multistore.Layouts, error)
}

LayoutBuilder is responsible for building Layouts

type MountableRouter

type MountableRouter struct {
	Prefix   string
	Delegate chronograf.Router
}

MountableRouter is an implementation of a chronograf.Router which supports prefixing each route of a Delegated chronograf.Router with a prefix.

func (*MountableRouter) DELETE

func (mr *MountableRouter) DELETE(path string, handler http.HandlerFunc)

DELETE defines a route responding to a DELETE request that will be prefixed with the configured route prefix

func (*MountableRouter) GET

func (mr *MountableRouter) GET(path string, handler http.HandlerFunc)

GET defines a route responding to a GET request that will be prefixed with the configured route prefix

func (*MountableRouter) Handler

func (mr *MountableRouter) Handler(method string, path string, handler http.Handler)

Handler defines a prefixed route responding to a request type specified in the method parameter

func (*MountableRouter) PATCH

func (mr *MountableRouter) PATCH(path string, handler http.HandlerFunc)

PATCH defines a route responding to a PATCH request that will be prefixed with the configured route prefix

func (*MountableRouter) POST

func (mr *MountableRouter) POST(path string, handler http.HandlerFunc)

POST defines a route responding to a POST request that will be prefixed with the configured route prefix

func (*MountableRouter) PUT

func (mr *MountableRouter) PUT(path string, handler http.HandlerFunc)

PUT defines a route responding to a PUT request that will be prefixed with the configured route prefix

func (*MountableRouter) ServeHTTP

func (mr *MountableRouter) ServeHTTP(rw http.ResponseWriter, r *http.Request)

ServeHTTP is an implementation of http.Handler which delegates to the configured Delegate's implementation of http.Handler

type MultiDashboardBuilder

type MultiDashboardBuilder struct {
	Logger chronograf.Logger
	ID     chronograf.ID
	Path   string
}

MultiDashboardBuilder builds a DashboardsStore backed by bolt and the filesystem

func (*MultiDashboardBuilder) Build

Build will construct a Dashboard store of filesystem and db-backed dashboards

type MultiKapacitorBuilder

type MultiKapacitorBuilder struct {
	KapacitorURL      string
	KapacitorUsername string
	KapacitorPassword string

	Logger chronograf.Logger
	ID     chronograf.ID
	Path   string
}

MultiKapacitorBuilder implements KapacitorBuilder

func (*MultiKapacitorBuilder) Build

Build will return a multistore facade KapacitorStore over memdb and bolt

type MultiLayoutBuilder

type MultiLayoutBuilder struct {
	Logger     chronograf.Logger
	UUID       chronograf.ID
	CannedPath string
}

MultiLayoutBuilder implements LayoutBuilder and will return a Layouts

func (*MultiLayoutBuilder) Build

Build will construct a Layouts of canned and db-backed personalized layouts

type MultiOrganizationBuilder

type MultiOrganizationBuilder struct {
	Logger chronograf.Logger
	Path   string
}

MultiOrganizationBuilder builds a OrganizationsStore backed by bolt and the filesystem

func (*MultiOrganizationBuilder) Build

Build will construct a Organization store of filesystem and db-backed dashboards

type MultiSourceBuilder

type MultiSourceBuilder struct {
	InfluxDBURL      string
	InfluxDBUsername string
	InfluxDBPassword string

	Logger chronograf.Logger
	ID     chronograf.ID
	Path   string
}

MultiSourceBuilder implements SourcesBuilder

func (*MultiSourceBuilder) Build

Build will return a MultiSourceStore

type MuxOpts

type MuxOpts struct {
	Logger        chronograf.Logger
	Develop       bool                 // Develop loads assets from filesystem instead of bindata
	Basepath      string               // URL path prefix under which all chronograf routes will be mounted
	UseAuth       bool                 // UseAuth turns on Github OAuth and JWT
	Auth          oauth2.Authenticator // Auth is used to authenticate and authorize
	ProviderFuncs []func(func(oauth2.Provider, oauth2.Mux))
	StatusFeedURL string            // JSON Feed URL for the client Status page News Feed
	CustomLinks   map[string]string // Any custom external links for client's User menu
	PprofEnabled  bool              // Mount pprof routes for profiling
}

MuxOpts are the options for the router. Mostly related to auth.

type OrganizationBuilder

type OrganizationBuilder interface {
	Build(chronograf.OrganizationsStore) (*multistore.OrganizationsStore, error)
}

OrganizationBuilder is responsible for building dashboards

type QueriesRequest

type QueriesRequest struct {
	Queries      []QueryRequest           `json:"queries"`
	TemplateVars []chronograf.TemplateVar `json:"tempVars,omitempty"`
}

QueriesRequest converts all queries to queryConfigs with the help of the template variables

type QueriesResponse

type QueriesResponse struct {
	Queries []QueryResponse `json:"queries"`
}

QueriesResponse is the response for a QueriesRequest

type QueryRequest

type QueryRequest struct {
	ID    string `json:"id"`
	Query string `json:"query"`
}

QueryRequest is query that will be converted to a queryConfig

type QueryResponse

type QueryResponse struct {
	Duration       int64                    `json:"durationMs"`
	ID             string                   `json:"id"`
	Query          string                   `json:"query"`
	QueryConfig    chronograf.QueryConfig   `json:"queryConfig"`
	QueryAST       *queries.SelectStatement `json:"queryAST,omitempty"`
	QueryTemplated *string                  `json:"queryTemplated,omitempty"`
}

QueryResponse is the return result of a QueryRequest including the raw query, the templated query, the queryConfig and the queryAST

type Server

type Server struct {
	Host string `long:"host" description:"The IP to listen on" default:"0.0.0.0" env:"HOST"`
	Port int    `` /* 126-byte string literal not displayed */

	PprofEnabled bool `long:"pprof-enabled" description:"Enable the /debug/pprof/* HTTP routes" env:"PPROF_ENABLED"`

	Cert flags.Filename `long:"cert" description:"Path to PEM encoded public key certificate. " env:"TLS_CERTIFICATE"`
	Key  flags.Filename `long:"key" description:"Path to private key associated with given certificate. " env:"TLS_PRIVATE_KEY"`

	InfluxDBURL      string `long:"influxdb-url" description:"Location of your InfluxDB instance" env:"INFLUXDB_URL"`
	InfluxDBUsername string `long:"influxdb-username" description:"Username for your InfluxDB instance" env:"INFLUXDB_USERNAME"`
	InfluxDBPassword string `long:"influxdb-password" description:"Password for your InfluxDB instance" env:"INFLUXDB_PASSWORD"`

	KapacitorURL      string `long:"kapacitor-url" description:"Location of your Kapacitor instance" env:"KAPACITOR_URL"`
	KapacitorUsername string `long:"kapacitor-username" description:"Username of your Kapacitor instance" env:"KAPACITOR_USERNAME"`
	KapacitorPassword string `long:"kapacitor-password" description:"Password of your Kapacitor instance" env:"KAPACITOR_PASSWORD"`

	NewSources string `` /* 589-byte string literal not displayed */

	Develop       bool          `short:"d" long:"develop" description:"Run server in develop mode."`
	BoltPath      string        `` /* 136-byte string literal not displayed */
	CannedPath    string        `` /* 160-byte string literal not displayed */
	ResourcesPath string        `` /* 190-byte string literal not displayed */
	TokenSecret   string        `short:"t" long:"token-secret" description:"Secret to sign tokens" env:"TOKEN_SECRET"`
	JwksURL       string        `long:"jwks-url" description:"URL that returns OpenID Key Discovery JWKS document." env:"JWKS_URL"`
	UseIDToken    bool          `long:"use-id-token" description:"Enable id_token processing." env:"USE_ID_TOKEN"`
	AuthDuration  time.Duration `` /* 179-byte string literal not displayed */

	GithubClientID     string   `short:"i" long:"github-client-id" description:"Github Client ID for OAuth 2 support" env:"GH_CLIENT_ID"`
	GithubClientSecret string   `short:"s" long:"github-client-secret" description:"Github Client Secret for OAuth 2 support" env:"GH_CLIENT_SECRET"`
	GithubOrgs         []string `` /* 141-byte string literal not displayed */

	GoogleClientID     string   `long:"google-client-id" description:"Google Client ID for OAuth 2 support" env:"GOOGLE_CLIENT_ID"`
	GoogleClientSecret string   `long:"google-client-secret" description:"Google Client Secret for OAuth 2 support" env:"GOOGLE_CLIENT_SECRET"`
	GoogleDomains      []string `` /* 133-byte string literal not displayed */
	PublicURL          string   `` /* 166-byte string literal not displayed */

	HerokuClientID      string   `long:"heroku-client-id" description:"Heroku Client ID for OAuth 2 support" env:"HEROKU_CLIENT_ID"`
	HerokuSecret        string   `long:"heroku-secret" description:"Heroku Secret for OAuth 2 support" env:"HEROKU_SECRET"`
	HerokuOrganizations []string `` /* 174-byte string literal not displayed */

	GenericName         string   `long:"generic-name" description:"Generic OAuth2 name presented on the login page"  env:"GENERIC_NAME"`
	GenericClientID     string   `long:"generic-client-id" description:"Generic OAuth2 Client ID. Can be used own OAuth2 service."  env:"GENERIC_CLIENT_ID"`
	GenericClientSecret string   `long:"generic-client-secret" description:"Generic OAuth2 Client Secret" env:"GENERIC_CLIENT_SECRET"`
	GenericScopes       []string `` /* 135-byte string literal not displayed */
	GenericDomains      []string `` /* 128-byte string literal not displayed */
	GenericAuthURL      string   `long:"generic-auth-url" description:"OAuth 2.0 provider's authorization endpoint URL" env:"GENERIC_AUTH_URL"`
	GenericTokenURL     string   `long:"generic-token-url" description:"OAuth 2.0 provider's token endpoint URL" env:"GENERIC_TOKEN_URL"`
	GenericAPIURL       string   `long:"generic-api-url" description:"URL that returns OpenID UserInfo compatible information." env:"GENERIC_API_URL"`
	GenericAPIKey       string   `` /* 148-byte string literal not displayed */

	Auth0Domain        string   `long:"auth0-domain" description:"Subdomain of auth0.com used for Auth0 OAuth2 authentication" env:"AUTH0_DOMAIN"`
	Auth0ClientID      string   `long:"auth0-client-id" description:"Auth0 Client ID for OAuth2 support" env:"AUTH0_CLIENT_ID"`
	Auth0ClientSecret  string   `long:"auth0-client-secret" description:"Auth0 Client Secret for OAuth2 support" env:"AUTH0_CLIENT_SECRET"`
	Auth0Organizations []string `` /* 140-byte string literal not displayed */
	Auth0SuperAdminOrg string   `` /* 148-byte string literal not displayed */

	StatusFeedURL          string            `` /* 177-byte string literal not displayed */
	CustomLinks            map[string]string `` /* 579-byte string literal not displayed */
	TelegrafSystemInterval time.Duration     `` /* 152-byte string literal not displayed */

	ReportingDisabled bool   `` /* 159-byte string literal not displayed */
	LogLevel          string `` //lint:ignore SA5008 duplicate tag choice is expected with go-flags.
	/* 157-byte string literal not displayed */
	Basepath    string `` /* 229-byte string literal not displayed */
	ShowVersion bool   `short:"v" long:"version" description:"Show Chronograf version info"`
	BuildInfo   chronograf.BuildInfo
	Listener    net.Listener
	// contains filtered or unexported fields
}

Server for the chronograf API

func (*Server) NewListener

func (s *Server) NewListener() (net.Listener, error)

NewListener will an http or https listener depending useTLS()

func (*Server) Serve

func (s *Server) Serve(ctx context.Context) error

Serve starts and runs the chronograf server

func (*Server) UseAuth0

func (s *Server) UseAuth0() bool

UseAuth0 validates the CLI parameters to enable Auth0 oauth support

func (*Server) UseGenericOAuth2

func (s *Server) UseGenericOAuth2() bool

UseGenericOAuth2 validates the CLI parameters to enable generic oauth support

func (*Server) UseGithub

func (s *Server) UseGithub() bool

UseGithub validates the CLI parameters to enable github oauth support

func (*Server) UseGoogle

func (s *Server) UseGoogle() bool

UseGoogle validates the CLI parameters to enable google oauth support

func (*Server) UseHeroku

func (s *Server) UseHeroku() bool

UseHeroku validates the CLI parameters to enable heroku oauth support

type Service

type Service struct {
	Store                    DataStore
	TimeSeriesClient         TimeSeriesClient
	Logger                   chronograf.Logger
	UseAuth                  bool
	SuperAdminProviderGroups superAdminProviderGroups
	Env                      chronograf.Environment
	Databases                chronograf.Databases
}

Service handles REST calls to the persistence

func NewServiceV2

func NewServiceV2(ctx context.Context, d *bbolt.DB) (*Service, error)

func (*Service) Annotation

func (s *Service) Annotation(w http.ResponseWriter, r *http.Request)

Annotation returns a specified annotation id within the annotations store

func (*Service) Annotations

func (s *Service) Annotations(w http.ResponseWriter, r *http.Request)

Annotations returns all annotations within the annotations store

func (*Service) AuthConfig

func (s *Service) AuthConfig(w http.ResponseWriter, r *http.Request)

AuthConfig retrieves the auth section of the global application configuration

func (*Service) Config

func (s *Service) Config(w http.ResponseWriter, r *http.Request)

Config retrieves the global application configuration

func (*Service) DashboardCellID

func (s *Service) DashboardCellID(w http.ResponseWriter, r *http.Request)

DashboardCellID gets a specific cell from an existing dashboard

func (*Service) DashboardCells

func (s *Service) DashboardCells(w http.ResponseWriter, r *http.Request)

DashboardCells returns all cells from a dashboard within the store

func (*Service) DashboardID

func (s *Service) DashboardID(w http.ResponseWriter, r *http.Request)

DashboardID returns a single specified dashboard

func (*Service) Dashboards

func (s *Service) Dashboards(w http.ResponseWriter, r *http.Request)

Dashboards returns all dashboards within the store

func (*Service) DefaultRP

func (s *Service) DefaultRP(ctx context.Context, qc *chronograf.QueryConfig, src *chronograf.Source) error

DefaultRP will add the default retention policy to the QC if one has not been specified

func (*Service) DropDatabase

func (h *Service) DropDatabase(w http.ResponseWriter, r *http.Request)

DropDatabase removes a database from a data source

func (*Service) DropRetentionPolicy

func (s *Service) DropRetentionPolicy(w http.ResponseWriter, r *http.Request)

DropRetentionPolicy removes a retention policy from a database

func (*Service) Environment

func (s *Service) Environment(w http.ResponseWriter, r *http.Request)

Environment retrieves the global application configuration

func (*Service) GetDatabases

func (h *Service) GetDatabases(w http.ResponseWriter, r *http.Request)

GetDatabases queries the list of all databases for a source

func (*Service) Influx

func (s *Service) Influx(w http.ResponseWriter, r *http.Request)

Influx proxies requests to influxdb.

func (*Service) Layouts

func (s *Service) Layouts(w http.ResponseWriter, r *http.Request)

Layouts retrieves all layouts from store

func (*Service) LayoutsID

func (s *Service) LayoutsID(w http.ResponseWriter, r *http.Request)

LayoutsID retrieves layout with ID from store

func (*Service) Mappings

func (s *Service) Mappings(w http.ResponseWriter, r *http.Request)

Mappings retrives all mappings

func (*Service) Me

func (s *Service) Me(w http.ResponseWriter, r *http.Request)

Me does a findOrCreate based on the username in the context

func (*Service) Measurements

func (h *Service) Measurements(w http.ResponseWriter, r *http.Request)

Measurements lists measurements within a database

func (*Service) NewAnnotation

func (s *Service) NewAnnotation(w http.ResponseWriter, r *http.Request)

NewAnnotation adds the annotation from a POST body to the annotations store

func (*Service) NewDashboard

func (s *Service) NewDashboard(w http.ResponseWriter, r *http.Request)

NewDashboard creates and returns a new dashboard object

func (*Service) NewDashboardCell

func (s *Service) NewDashboardCell(w http.ResponseWriter, r *http.Request)

NewDashboardCell adds a cell to an existing dashboard

func (*Service) NewDatabase

func (h *Service) NewDatabase(w http.ResponseWriter, r *http.Request)

NewDatabase creates a new database within the datastore

func (*Service) NewMapping

func (s *Service) NewMapping(w http.ResponseWriter, r *http.Request)

NewMapping adds a new mapping

func (*Service) NewOrganization

func (s *Service) NewOrganization(w http.ResponseWriter, r *http.Request)

NewOrganization adds a new organization to store

func (*Service) NewRetentionPolicy

func (h *Service) NewRetentionPolicy(w http.ResponseWriter, r *http.Request)

NewRetentionPolicy creates a new retention policy for a database

func (*Service) NewService

func (s *Service) NewService(w http.ResponseWriter, r *http.Request)

NewService adds valid service store store.

func (*Service) NewTemplate

func (s *Service) NewTemplate(w http.ResponseWriter, r *http.Request)

NewTemplate adds a template to an existing dashboard

func (*Service) NewUser

func (s *Service) NewUser(w http.ResponseWriter, r *http.Request)

NewUser adds a new Chronograf user to store

func (*Service) OrganizationConfig

func (s *Service) OrganizationConfig(w http.ResponseWriter, r *http.Request)

OrganizationConfig retrieves the organization-wide config settings

func (*Service) OrganizationID

func (s *Service) OrganizationID(w http.ResponseWriter, r *http.Request)

OrganizationID retrieves a organization with ID from store

func (*Service) OrganizationLogViewerConfig

func (s *Service) OrganizationLogViewerConfig(w http.ResponseWriter, r *http.Request)

OrganizationLogViewerConfig retrieves the log viewer UI section of the organization config This uses a FindOrCreate function to ensure that any new organizations have default organization config values, without having to associate organization creation with organization config creation.

func (*Service) Organizations

func (s *Service) Organizations(w http.ResponseWriter, r *http.Request)

Organizations retrieves all organizations from store

func (*Service) Permissions

func (s *Service) Permissions(w http.ResponseWriter, r *http.Request)

Permissions returns all possible permissions for this source.

func (*Service) Proxy

func (s *Service) Proxy(w http.ResponseWriter, r *http.Request)

Proxy proxies requests to services using the path query parameter.

func (*Service) ProxyDelete

func (s *Service) ProxyDelete(w http.ResponseWriter, r *http.Request)

ProxyDelete proxies DELETE to service

func (*Service) ProxyGet

func (s *Service) ProxyGet(w http.ResponseWriter, r *http.Request)

ProxyGet proxies GET to service

func (*Service) ProxyPatch

func (s *Service) ProxyPatch(w http.ResponseWriter, r *http.Request)

ProxyPatch proxies PATCH to Service

func (*Service) ProxyPost

func (s *Service) ProxyPost(w http.ResponseWriter, r *http.Request)

ProxyPost proxies POST to service

func (*Service) Queries

func (s *Service) Queries(w http.ResponseWriter, r *http.Request)

Queries analyzes InfluxQL to produce front-end friendly QueryConfig

func (*Service) RemoveAnnotation

func (s *Service) RemoveAnnotation(w http.ResponseWriter, r *http.Request)

RemoveAnnotation removes the annotation from the time series source

func (*Service) RemoveDashboard

func (s *Service) RemoveDashboard(w http.ResponseWriter, r *http.Request)

RemoveDashboard deletes a dashboard

func (*Service) RemoveDashboardCell

func (s *Service) RemoveDashboardCell(w http.ResponseWriter, r *http.Request)

RemoveDashboardCell removes a specific cell from an existing dashboard

func (*Service) RemoveMapping

func (s *Service) RemoveMapping(w http.ResponseWriter, r *http.Request)

RemoveMapping removes a mapping

func (*Service) RemoveOrganization

func (s *Service) RemoveOrganization(w http.ResponseWriter, r *http.Request)

RemoveOrganization removes an organization in the organizations store

func (*Service) RemoveService

func (s *Service) RemoveService(w http.ResponseWriter, r *http.Request)

RemoveService deletes service from store.

func (*Service) RemoveTemplate

func (s *Service) RemoveTemplate(w http.ResponseWriter, r *http.Request)

RemoveTemplate removes a specific template from an existing dashboard

func (*Service) RemoveUser

func (s *Service) RemoveUser(w http.ResponseWriter, r *http.Request)

RemoveUser deletes a Chronograf user from store

func (*Service) ReplaceAuthConfig

func (s *Service) ReplaceAuthConfig(w http.ResponseWriter, r *http.Request)

ReplaceAuthConfig replaces the auth section of the global application configuration

func (*Service) ReplaceDashboard

func (s *Service) ReplaceDashboard(w http.ResponseWriter, r *http.Request)

ReplaceDashboard completely replaces a dashboard

func (*Service) ReplaceDashboardCell

func (s *Service) ReplaceDashboardCell(w http.ResponseWriter, r *http.Request)

ReplaceDashboardCell replaces a cell entirely within an existing dashboard

func (*Service) ReplaceOrganizationLogViewerConfig

func (s *Service) ReplaceOrganizationLogViewerConfig(w http.ResponseWriter, r *http.Request)

ReplaceOrganizationLogViewerConfig replaces the log viewer UI section of the organization config

func (*Service) ReplaceTemplate

func (s *Service) ReplaceTemplate(w http.ResponseWriter, r *http.Request)

ReplaceTemplate replaces a template entirely within an existing dashboard

func (*Service) RetentionPolicies

func (h *Service) RetentionPolicies(w http.ResponseWriter, r *http.Request)

RetentionPolicies lists retention policies within a database

func (*Service) ServiceID

func (s *Service) ServiceID(w http.ResponseWriter, r *http.Request)

ServiceID retrieves a service with ID from store.

func (*Service) Services

func (s *Service) Services(w http.ResponseWriter, r *http.Request)

Services retrieves all services from store.

func (*Service) TemplateID

func (s *Service) TemplateID(w http.ResponseWriter, r *http.Request)

TemplateID retrieves a specific template from a dashboard

func (*Service) Templates

func (s *Service) Templates(w http.ResponseWriter, r *http.Request)

Templates returns all templates from a dashboard within the store

func (*Service) TimeSeries

func (s *Service) TimeSeries(src chronograf.Source) (chronograf.TimeSeries, error)

TimeSeries returns a new client connected to a time series database

func (*Service) UpdateAnnotation

func (s *Service) UpdateAnnotation(w http.ResponseWriter, r *http.Request)

UpdateAnnotation overwrite an existing annotation

func (*Service) UpdateDashboard

func (s *Service) UpdateDashboard(w http.ResponseWriter, r *http.Request)

UpdateDashboard completely updates either the dashboard name or the cells

func (*Service) UpdateMapping

func (s *Service) UpdateMapping(w http.ResponseWriter, r *http.Request)

UpdateMapping updates a mapping

func (*Service) UpdateMe

func (s *Service) UpdateMe(auth oauth2.Authenticator) func(http.ResponseWriter, *http.Request)

UpdateMe changes the user's current organization on the JWT and responds with the same semantics as Me

func (*Service) UpdateOrganization

func (s *Service) UpdateOrganization(w http.ResponseWriter, r *http.Request)

UpdateOrganization updates an organization in the organizations store

func (*Service) UpdateRetentionPolicy

func (h *Service) UpdateRetentionPolicy(w http.ResponseWriter, r *http.Request)

UpdateRetentionPolicy modifies an existing retention policy for a database

func (*Service) UpdateService

func (s *Service) UpdateService(w http.ResponseWriter, r *http.Request)

UpdateService incrementally updates a service definition in the store

func (*Service) UpdateUser

func (s *Service) UpdateUser(w http.ResponseWriter, r *http.Request)

UpdateUser updates a Chronograf user in store

func (*Service) UserID

func (s *Service) UserID(w http.ResponseWriter, r *http.Request)

UserID retrieves a Chronograf user with ID from store

func (*Service) Users

func (s *Service) Users(w http.ResponseWriter, r *http.Request)

Users retrieves all Chronograf users from store

func (*Service) Write

func (s *Service) Write(w http.ResponseWriter, r *http.Request)

type SourcesBuilder

type SourcesBuilder interface {
	Build(chronograf.SourcesStore) (*multistore.SourcesStore, error)
}

SourcesBuilder builds a MultiSourceStore

type Store

type Store struct {
	SourcesStore            chronograf.SourcesStore
	ServersStore            chronograf.ServersStore
	LayoutsStore            chronograf.LayoutsStore
	UsersStore              chronograf.UsersStore
	DashboardsStore         chronograf.DashboardsStore
	MappingsStore           chronograf.MappingsStore
	OrganizationsStore      chronograf.OrganizationsStore
	ConfigStore             chronograf.ConfigStore
	OrganizationConfigStore chronograf.OrganizationConfigStore
}

Store implements the DataStore interface

func (*Store) Config

func (s *Store) Config(ctx context.Context) chronograf.ConfigStore

Config returns the underlying ConfigStore.

func (*Store) Dashboards

func (s *Store) Dashboards(ctx context.Context) chronograf.DashboardsStore

Dashboards returns a noop.DashboardsStore if the context has no organization specified and an organization.DashboardsStore otherwise.

func (*Store) Layouts

func (s *Store) Layouts(ctx context.Context) chronograf.LayoutsStore

Layouts returns all layouts in the underlying layouts store.

func (*Store) Mappings

func (s *Store) Mappings(ctx context.Context) chronograf.MappingsStore

Mappings returns the underlying MappingsStore.

func (*Store) OrganizationConfig

func (s *Store) OrganizationConfig(ctx context.Context) chronograf.OrganizationConfigStore

OrganizationConfig returns a noop.OrganizationConfigStore if the context has no organization specified and an organization.OrganizationConfigStore otherwise.

func (*Store) Organizations

func (s *Store) Organizations(ctx context.Context) chronograf.OrganizationsStore

Organizations returns the underlying OrganizationsStore.

func (*Store) Servers

func (s *Store) Servers(ctx context.Context) chronograf.ServersStore

Servers returns a noop.ServersStore if the context has no organization specified and an organization.ServersStore otherwise.

func (*Store) Sources

func (s *Store) Sources(ctx context.Context) chronograf.SourcesStore

Sources returns a noop.SourcesStore if the context has no organization specified and an organization.SourcesStore otherwise.

func (*Store) Users

func (s *Store) Users(ctx context.Context) chronograf.UsersStore

Users returns a chronograf.UsersStore. If the context is a server context, then the underlying chronograf.UsersStore is returned. If there is an organization specified on context, then an organizations.UsersStore is returned. If niether are specified, a noop.UsersStore is returned.

type TimeSeriesClient

type TimeSeriesClient interface {
	New(chronograf.Source, chronograf.Logger) (chronograf.TimeSeries, error)
}

TimeSeriesClient returns the correct client for a time series database.

type URLPrefixer

type URLPrefixer struct {
	Prefix string            // the prefix to be appended after any detected Attrs
	Next   http.Handler      // the http.Handler which will generate the content to be modified by this handler
	Attrs  [][]byte          // a list of attrs that should have their URLs prefixed. For example `src="` or `href="` would be valid
	Logger chronograf.Logger // The logger where prefixing errors will be dispatched to
}

URLPrefixer is a wrapper for an http.Handler that will prefix all occurrences of a relative URL with the configured Prefix

func NewDefaultURLPrefixer

func NewDefaultURLPrefixer(prefix string, next http.Handler, lg chronograf.Logger) *URLPrefixer

NewDefaultURLPrefixer returns a URLPrefixer that will prefix any src and href attributes found in HTML as well as any url() directives found in CSS with the provided prefix. Additionally, it will prefix any `data-basepath` attributes as well for informing front end logic about any prefixes. `next` is the next http.Handler that will have its output prefixed

func (*URLPrefixer) ServeHTTP

func (up *URLPrefixer) ServeHTTP(rw http.ResponseWriter, r *http.Request)

ServeHTTP implements an http.Handler that prefixes relative URLs from the Next handler with the configured prefix. It does this by examining the stream through the ResponseWriter, and appending the Prefix after any of the Attrs detected in the stream.

Jump to

Keyboard shortcuts

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