influx

package
v0.0.0-...-47cc4bd Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: AGPL-3.0, AGPL-3.0-or-later Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AllAnnotations returns all annotations from the chronograf database
	AllAnnotations = `SELECT * FROM "annotations" WHERE "deleted"=false AND time >= %dns and "start_time" <= %d %s ORDER BY time DESC`
	// GetAnnotationID returns all annotations from the chronograf database where id is %s
	GetAnnotationID = `SELECT * FROM "annotations" WHERE "id"='%s' AND "deleted"=false ORDER BY time DESC`
	// AnnotationsDB is chronograf.  Perhaps later we allow this to be changed
	AnnotationsDB = "chronograf"
	// DefaultRP is autogen. Perhaps later we allow this to be changed
	DefaultRP = "autogen"
	// DefaultMeasurement is annotations.
	DefaultMeasurement = "annotations"
)
View Source
const WhereToken = "WHERE"

WhereToken is used to parse the time expression from an influxql query

Variables

View Source
var (
	// AllowAllDB means a user gets both read and write permissions for a db
	AllowAllDB = chronograf.Allowances{"WRITE", "READ"}
	// AllowAllAdmin means a user gets both read and write permissions for an admin
	AllowAllAdmin = chronograf.Allowances{"ALL"}
	// AllowRead means a user is only able to read the database.
	AllowRead = chronograf.Allowances{"READ"}
	// AllowWrite means a user is able to only write to the database
	AllowWrite = chronograf.Allowances{"WRITE"}
	// NoPrivileges occasionally shows up as a response for a users grants.
	NoPrivileges = "NO PRIVILEGES"
	// AllPrivileges means that a user has both read and write perms
	AllPrivileges = "ALL PRIVILEGES"
	// All means a user has both read and write perms. Alternative to AllPrivileges
	All = "ALL"
	// Read means a user can read a database
	Read = "READ"
	// Write means a user can write to a database
	Write = "WRITE"
)

Functions

func Convert

func Convert(influxQL string) (chronograf.QueryConfig, error)

Convert changes an InfluxQL query to a QueryConfig

func Difference

Difference compares two permission sets and returns a set to be revoked and a set to be added

func JWT

func JWT(username, sharedSecret string, now Now) (string, error)

JWT returns a token string accepted by InfluxDB using the sharedSecret as an Authorization: Bearer header

func ParseTime

func ParseTime(influxQL string, now time.Time) (time.Duration, error)

ParseTime extracts the duration of the time range of the query

func SharedTransport

func SharedTransport(skipVerify bool) *http.Transport

SharedTransport returns a shared transport with requested TLS InsecureSkipVerify value

func TimeRangeAsEpochNano

func TimeRangeAsEpochNano(expr influxql.Expr, now time.Time) (min, max int64, err error)

TimeRangeAsEpochNano extracs the min and max epoch times from the expression

func ToGrant

func ToGrant(username string, perm chronograf.Permission) string

ToGrant converts the permission into InfluxQL grants

func ToInfluxQL

func ToInfluxQL(action, preposition, username string, perm chronograf.Permission) string

ToInfluxQL converts the permission into InfluxQL

func ToPriv

func ToPriv(a chronograf.Allowances) string

ToPriv converts chronograf allowances to InfluxQL

func ToRevoke

func ToRevoke(username string, perm chronograf.Permission) string

ToRevoke converts the permission into InfluxQL revokes

Types

type AnnotationStore

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

AnnotationStore stores annotations within InfluxDB

func NewAnnotationStore

func NewAnnotationStore(client chronograf.TimeSeries) *AnnotationStore

NewAnnotationStore constructs an annoation store with a client

func (*AnnotationStore) Add

Add creates a new annotation in the store

func (*AnnotationStore) All

All lists all Annotations

func (*AnnotationStore) Delete

func (a *AnnotationStore) Delete(ctx context.Context, id string) error

Delete removes the annotation from the store

func (*AnnotationStore) Get

Get retrieves an annotation

func (*AnnotationStore) Update

func (a *AnnotationStore) Update(ctx context.Context, anno *chronograf.Annotation) error

Update replaces annotation; if the annotation's time is different, it also removes the previous annotation

type Authorizer

type Authorizer interface {
	// Set may manipulate the request by adding the Authorization header
	Set(req *http.Request) error
}

Authorizer adds optional authorization header to request

func DefaultAuthorization

func DefaultAuthorization(src *chronograf.Source) Authorizer

DefaultAuthorization creates either a shared JWT builder, basic auth or Noop or Token authentication

type BasicAuth

type BasicAuth struct {
	Username string
	Password string
}

BasicAuth adds Authorization: Basic to the request header

func (*BasicAuth) Set

func (b *BasicAuth) Set(r *http.Request) error

Set adds the basic auth headers to the request

type BearerJWT

type BearerJWT struct {
	Username     string
	SharedSecret string
	Now          Now
}

BearerJWT is the default Bearer for InfluxDB

func (*BearerJWT) Set

func (b *BearerJWT) Set(r *http.Request) error

Set adds an Authorization Bearer to the request if has a shared secret

func (*BearerJWT) Token

func (b *BearerJWT) Token(username string) (string, error)

Token returns the expected InfluxDB JWT signed with the sharedSecret

type Client

type Client struct {
	URL                *url.URL
	Authorizer         Authorizer
	InsecureSkipVerify bool
	Logger             chronograf.Logger
}

Client is a device for retrieving time series data from an InfluxDB instance

func (*Client) Add

func (c *Client) Add(ctx context.Context, u *chronograf.User) (*chronograf.User, error)

Add a new User in InfluxDB

func (*Client) All

func (c *Client) All(ctx context.Context) ([]chronograf.User, error)

All users in influx

func (*Client) AllDB

func (c *Client) AllDB(ctx context.Context) ([]chronograf.Database, error)

AllDB returns all databases from within Influx

func (*Client) AllRP

func (c *Client) AllRP(ctx context.Context, db string) ([]chronograf.RetentionPolicy, error)

AllRP returns all the retention policies for a specific database

func (*Client) Connect

func (c *Client) Connect(ctx context.Context, src *chronograf.Source) error

Connect caches the URL and optional Bearer Authorization for the data source

func (*Client) CreateDB

func (c *Client) CreateDB(ctx context.Context, db *chronograf.Database) (*chronograf.Database, error)

CreateDB creates a database within Influx

func (*Client) CreateRP

CreateRP creates a retention policy for a specific database

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, u *chronograf.User) error

Delete the User from InfluxDB

func (*Client) DropDB

func (c *Client) DropDB(ctx context.Context, db string) error

DropDB drops a database within Influx

func (*Client) DropRP

func (c *Client) DropRP(ctx context.Context, db string, rp string) error

DropRP removes a specific retention policy for a specific database

func (*Client) Get

Get retrieves a user if name exists.

func (*Client) GetMeasurements

func (c *Client) GetMeasurements(ctx context.Context, db string, limit, offset int) ([]chronograf.Measurement, error)

GetMeasurements returns measurements in a specified database, paginated by optional limit and offset. If no limit or offset is provided, it defaults to a limit of 100 measurements with no offset.

func (*Client) Num

func (c *Client) Num(ctx context.Context) (int, error)

Num is the number of users in DB

func (*Client) Permissions

func (c *Client) Permissions(context.Context) chronograf.Permissions

Permissions return just READ and WRITE for OSS Influx

func (*Client) Ping

func (c *Client) Ping(ctx context.Context) error

Ping hits the influxdb ping endpoint and returns the type of influx

func (*Client) Query

Query issues a request to a configured InfluxDB instance for time series information specified by query. Queries must be "fully-qualified," and include both the database and retention policy. In-flight requests can be cancelled using the provided context.

func (*Client) Roles

func (c *Client) Roles(ctx context.Context) (chronograf.RolesStore, error)

Roles aren't support in OSS

func (*Client) Type

func (c *Client) Type(ctx context.Context) (string, error)

Type hits the influxdb ping endpoint and returns the type of influx running

func (*Client) Update

func (c *Client) Update(ctx context.Context, u *chronograf.User) error

Update the user's permissions or roles

func (*Client) UpdateRP

UpdateRP updates a specific retention policy for a specific database

func (*Client) Users

func (c *Client) Users(ctx context.Context) chronograf.UsersStore

Users transforms InfluxDB into a user store

func (*Client) ValidateAuth

func (c *Client) ValidateAuth(ctx context.Context, src *chronograf.Source) error

ValidateAuth returns error when an authenticated communication with the source fails

func (*Client) Version

func (c *Client) Version(ctx context.Context) (string, error)

Version hits the influxdb ping endpoint and returns the version of influx

func (*Client) Write

func (c *Client) Write(ctx context.Context, points []chronograf.Point) error

Write POSTs line protocol to a database and retention policy

type NoAuthorization

type NoAuthorization struct{}

NoAuthorization does not add any authorization headers

func (*NoAuthorization) Set

func (n *NoAuthorization) Set(req *http.Request) error

Set does not add authorization

type Now

type Now func() time.Time

Now returns the current time

type TokenAuth

type TokenAuth struct {
	Token string
}

TokenAuth adds Authorization: Token to the request header

func (*TokenAuth) Set

func (a *TokenAuth) Set(r *http.Request) error

Set adds the token authentication to the request

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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