Documentation ¶
Index ¶
- Constants
- Variables
- func Convert(influxQL string) (chronograf.QueryConfig, error)
- func Difference(wants chronograf.Permissions, haves chronograf.Permissions) (revoke chronograf.Permissions, add chronograf.Permissions)
- func JWT(username, sharedSecret string, now Now) (string, error)
- func ParseTime(influxQL string, now time.Time) (time.Duration, error)
- func TimeRangeAsEpochNano(expr influxql.Expr, now time.Time) (min, max int64, err error)
- func ToGrant(username string, perm chronograf.Permission) string
- func ToInfluxQL(action, preposition, username string, perm chronograf.Permission) string
- func ToPriv(a chronograf.Allowances) string
- func ToRevoke(username string, perm chronograf.Permission) string
- type AnnotationStore
- func (a *AnnotationStore) Add(ctx context.Context, anno *chronograf.Annotation) (*chronograf.Annotation, error)
- func (a *AnnotationStore) All(ctx context.Context, start, stop time.Time) ([]chronograf.Annotation, error)
- func (a *AnnotationStore) Delete(ctx context.Context, id string) error
- func (a *AnnotationStore) Get(ctx context.Context, id string) (*chronograf.Annotation, error)
- func (a *AnnotationStore) Update(ctx context.Context, anno *chronograf.Annotation) error
- type Authorizer
- type BasicAuth
- type BearerJWT
- type Client
- func (c *Client) Add(ctx context.Context, u *chronograf.User) (*chronograf.User, error)
- func (c *Client) All(ctx context.Context) ([]chronograf.User, error)
- func (c *Client) AllDB(ctx context.Context) ([]chronograf.Database, error)
- func (c *Client) AllRP(ctx context.Context, db string) ([]chronograf.RetentionPolicy, error)
- func (c *Client) Connect(ctx context.Context, src *chronograf.Source) error
- func (c *Client) CreateDB(ctx context.Context, db *chronograf.Database) (*chronograf.Database, error)
- func (c *Client) CreateRP(ctx context.Context, db string, rp *chronograf.RetentionPolicy) (*chronograf.RetentionPolicy, error)
- func (c *Client) Delete(ctx context.Context, u *chronograf.User) error
- func (c *Client) DropDB(ctx context.Context, db string) error
- func (c *Client) DropRP(ctx context.Context, db string, rp string) error
- func (c *Client) Get(ctx context.Context, q chronograf.UserQuery) (*chronograf.User, error)
- func (c *Client) GetMeasurements(ctx context.Context, db string, limit, offset int) ([]chronograf.Measurement, error)
- func (c *Client) Num(ctx context.Context) (int, error)
- func (c *Client) Permissions(context.Context) chronograf.Permissions
- func (c *Client) Ping(ctx context.Context) error
- func (c *Client) Query(ctx context.Context, q chronograf.Query) (chronograf.Response, error)
- func (c *Client) Roles(ctx context.Context) (chronograf.RolesStore, error)
- func (c *Client) Type(ctx context.Context) (string, error)
- func (c *Client) Update(ctx context.Context, u *chronograf.User) error
- func (c *Client) UpdateRP(ctx context.Context, db string, rp string, upd *chronograf.RetentionPolicy) (*chronograf.RetentionPolicy, error)
- func (c *Client) Users(ctx context.Context) chronograf.UsersStore
- func (c *Client) Version(ctx context.Context) (string, error)
- func (c *Client) Write(ctx context.Context, points []chronograf.Point) error
- type NoAuthorization
- type Now
- type Response
Constants ¶
const ( // AllAnnotations returns all annotations from the chronograf database AllAnnotations = `` /* 161-byte string literal not displayed */ // GetAnnotationID returns all annotations from the chronograf database where id is %s GetAnnotationID = `` /* 135-byte string literal not displayed */ // 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" )
const WhereToken = "WHERE"
WhereToken is used to parse the time expression from an influxql query
Variables ¶
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 ¶
func Difference(wants chronograf.Permissions, haves chronograf.Permissions) (revoke chronograf.Permissions, add chronograf.Permissions)
Difference compares two permission sets and returns a set to be revoked and a set to be added
func JWT ¶
JWT returns a token string accepted by InfluxDB using the sharedSecret as an Authorization: Bearer header
func TimeRangeAsEpochNano ¶
TimeRangeAsEpochNano extracts 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 ¶
func (a *AnnotationStore) Add(ctx context.Context, anno *chronograf.Annotation) (*chronograf.Annotation, error)
Add creates a new annotation in the store
func (*AnnotationStore) All ¶
func (a *AnnotationStore) All(ctx context.Context, start, stop time.Time) ([]chronograf.Annotation, error)
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 ¶
func (a *AnnotationStore) Get(ctx context.Context, id string) (*chronograf.Annotation, error)
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
type BearerJWT ¶
BearerJWT is the default Bearer for InfluxDB
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) 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 ¶
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 ¶
func (c *Client) CreateRP(ctx context.Context, db string, rp *chronograf.RetentionPolicy) (*chronograf.RetentionPolicy, error)
CreateRP creates a retention policy for a specific database
func (*Client) Get ¶
func (c *Client) Get(ctx context.Context, q chronograf.UserQuery) (*chronograf.User, error)
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) Permissions ¶
func (c *Client) Permissions(context.Context) chronograf.Permissions
Permissions return just READ and WRITE for OSS Influx
func (*Client) Query ¶
func (c *Client) Query(ctx context.Context, q chronograf.Query) (chronograf.Response, error)
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) UpdateRP ¶
func (c *Client) UpdateRP(ctx context.Context, db string, rp string, upd *chronograf.RetentionPolicy) (*chronograf.RetentionPolicy, error)
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
type NoAuthorization ¶
type NoAuthorization struct{}
NoAuthorization does not add any authorization headers
type Response ¶
type Response struct { Results json.RawMessage Err string `json:"error,omitempty"` }
Response is a partial JSON decoded InfluxQL response used to check for some errors
func (Response) MarshalJSON ¶
MarshalJSON returns the raw results bytes from the response