Documentation ¶
Index ¶
- Constants
- Variables
- func CreateMeasurement(org, bucket []byte) ([]byte, error)
- func ErrorCode(err error) string
- func ErrorMessage(err error) string
- func ErrorOp(err error) string
- func IsActive(a *Authorization) bool
- func MarshalViewPropertiesJSON(v ViewProperties) ([]byte, error)
- func PermissionAllowed(p Permission, ps []Permission) bool
- func ReadMeasurement(name []byte) (orgID, bucketID []byte, err error)
- func SortDashboards(by string, ds []*Dashboard)
- func ValidScraperType(s string) bool
- func WithErrorCode(code string) func(*Error)
- func WithErrorErr(err error) func(*Error)
- func WithErrorMsg(msg string) func(*Error)
- func WithErrorOp(op string) func(*Error)
- type Action
- type AddDashboardCellOptions
- type Authorization
- type AuthorizationFilter
- type AuthorizationService
- type Authorizer
- type Axis
- type BasicAuthService
- type Bucket
- type BucketFilter
- type BucketOperationLogService
- type BucketService
- type BucketType
- type BucketUpdate
- type BuilderConfig
- type Cell
- type CellUpdate
- type ChronografError
- type DBRPMapping
- type DBRPMappingFilter
- type DBRPMappingService
- type Dashboard
- type DashboardFilter
- type DashboardMeta
- type DashboardOperationLogService
- type DashboardQuery
- type DashboardService
- type DashboardUpdate
- type DecimalPlaces
- type EmptyViewProperties
- type Error
- type FindOptions
- type GaugeViewProperties
- type ID
- type IDGenerator
- type KeyValueLog
- type Label
- type LabelFilter
- type LabelService
- type LabelUpdate
- type Legend
- type LinePlusSingleStatProperties
- type Log
- type LogColumnSetting
- type LogFilter
- type LogViewProperties
- type LogViewerColumn
- type LookupService
- type Macro
- type MacroArguments
- type MacroConstantValues
- type MacroMapValues
- type MacroQueryValues
- type MacroService
- type MacroUpdate
- type MarkdownViewProperties
- type OnboardingRequest
- type OnboardingResults
- type OnboardingService
- type OperationLogEntry
- type Organization
- type OrganizationFilter
- type OrganizationOperationLogService
- type OrganizationService
- type OrganizationUpdate
- type PagingFilter
- type PagingLinks
- type Permission
- type Proto
- type ProtoDashboard
- type ProtoService
- type RenamableField
- type Resource
- type Run
- type RunFilter
- type ScraperTarget
- type ScraperTargetFilter
- type ScraperTargetStoreService
- type ScraperType
- type SecretService
- type Session
- type SessionService
- type SingleStatViewProperties
- type Source
- type SourceFields
- type SourceQuery
- type SourceService
- type SourceType
- type SourceUpdate
- type Status
- type TableOptions
- type TableViewProperties
- type Task
- type TaskFilter
- type TaskService
- type TaskUpdate
- type TelegrafAgentConfig
- type TelegrafConfig
- type TelegrafConfigFilter
- type TelegrafConfigStore
- type TelegrafPlugin
- type Timespan
- type TokenGenerator
- type Usage
- type UsageFilter
- type UsageMetric
- type UsageService
- type User
- type UserFilter
- type UserOperationLogService
- type UserResourceMapping
- type UserResourceMappingFilter
- type UserResourceMappingService
- type UserService
- type UserType
- type UserUpdate
- type V1SourceFields
- type View
- type ViewColor
- type ViewContents
- type ViewContentsUpdate
- type ViewFilter
- type ViewProperties
- type ViewService
- type ViewUpdate
- type WriteService
- type XYViewProperties
Examples ¶
Constants ¶
const ( OpFindAuthorizationByID = "FindAuthorizationByID" OpFindAuthorizationByToken = "FindAuthorizationByToken" OpFindAuthorizations = "FindAuthorizations" OpCreateAuthorization = "CreateAuthorization" OpSetAuthorizationStatus = "SetAuthorizationStatus" OpDeleteAuthorization = "DeleteAuthorization" )
auth service op
const ( // AuthorizationsResource gives permissions to one or more authorizations. AuthorizationsResource = Resource("authorizations") // 0 // BucketsResource gives permissions to one or more buckets. BucketsResource = Resource("buckets") // 1 // DashboardsResource gives permissions to one or more dashboards. DashboardsResource = Resource("dashboards") // 2 // OrgsResource gives permissions to one or more orgs. OrgsResource = Resource("orgs") // 3 // SourcesResource gives permissions to one or more sources. SourcesResource = Resource("sources") // 4 // TasksResource gives permissions to one or more tasks. TasksResource = Resource("tasks") // 5 // TelegrafsResource type gives permissions to a one or more telegrafs. TelegrafsResource = Resource("telegrafs") // 6 // UsersResource gives permissions to one or more users. UsersResource = Resource("users") // 7 )
const ( OpFindDashboardByID = "FindDashboardByID" OpFindDashboards = "FindDashboards" OpCreateDashboard = "CreateDashboard" OpUpdateDashboard = "UpdateDashboard" OpAddDashboardCell = "AddDashboardCell" OpRemoveDashboardCell = "RemoveDashboardCell" OpUpdateDashboardCell = "UpdateDashboardCell" OpGetDashboardCellView = "GetDashboardCellView" OpUpdateDashboardCellView = "UpdateDashboardCellView" OpDeleteDashboard = "DeleteDashboard" OpReplaceDashboardCells = "ReplaceDashboardCells" )
ops for dashboard service.
const ( EInternal = "internal error" ENotFound = "not found" EConflict = "conflict" // action cannot be performed EInvalid = "invalid" // validation failed EEmptyValue = "empty value" EForbidden = "forbidden" EMethodNotAllowed = "method not allowed" )
Some error code constant, ideally we want define common platform codes here projects on use platform's error, should have their own central place like this.
const ( OpFindLabels = "FindLabels" OpCreateLabel = "CreateLabel" OpUpdateLabel = "UpdateLabel" OpDeleteLabel = "DeleteLabel" )
const ( OpFindMacroByID = "FindMacroByID" OpFindMacros = "FindMacros" OpCreateMacro = "CreateMacro" OpUpdateMacro = "UpdateMacro" OpReplaceMacro = "ReplaceMacro" OpDeleteMacro = "DeleteMacro" )
ops for macro error.
const ( OrgIDLength = 8 BucketIDLength = 8 MeasurementLength = OrgIDLength + BucketIDLength )
Length of components of measurement names.
const ( OpFindOrganizationByID = "FindOrganizationByID" OpFindOrganization = "FindOrganization" OpFindOrganizations = "FindOrganizations" OpCreateOrganization = "CreateOrganization" OpUpdateOrganization = "UpdateOrganization" OpDeleteOrganization = "DeleteOrganization" )
ops for orgs error and orgs op logs.
const ( DefaultPageSize = 20 MaxPageSize = 100 )
const ( OpListTargets = "ListTargets" OpAddTarget = "AddTarget" OpGetTargetByID = "GetTargetByID" OpRemoveTarget = "RemoveTarget" OpUpdateTarget = "UpdateTarget" )
ops for ScraperTarget Store
const ( // V2SourceType is an InfluxDBv2 type. V2SourceType = "v2" // V1SourceType is an InfluxDBv1 type. V1SourceType = "v1" // SelfSourceType is the source hosting the UI. SelfSourceType = "self" )
const ( OpDefaultSource = "DefaultSource" OpFindSourceByID = "FindSourceByID" OpFindSources = "FindSources" OpCreateSource = "CreateSource" OpUpdateSource = "UpdateSource" OpDeleteSource = "DeleteSource" )
ops for sources.
const ( TaskDefaultPageSize = 100 TaskMaxPageSize = 500 )
const ( ErrTelegrafPluginNameUnmatch = "the telegraf plugin is name %s doesn't match the config %s" ErrNoTelegrafPlugins = "there is no telegraf plugin in the config" ErrUnsupportTelegrafPluginType = "unsupported telegraf plugin type %s" ErrUnsupportTelegrafPluginName = "unsupported telegraf plugin %s, type %s" )
errors
const ( OpFindUserByID = "FindUserByID" OpFindUser = "FindUser" OpFindUsers = "FindUsers" OpCreateUser = "CreateUser" OpUpdateUser = "UpdateUser" OpDeleteUser = "DeleteUser" )
Ops for user errors and op log.
const ( OpFindViewByID = "FindViewByID" OpFindViews = "FindViews" OpCreateView = "CreateView" OpUpdateView = "UpdateView" OpDeleteView = "DeleteView" )
ops for view.
const ( // BucketTypeLogs defines the bucket ID of the system logs. BucketTypeLogs = BucketType(iota + 10) )
const ErrCellNotFound = "cell not found"
ErrCellNotFound is the error msg for a missing cell.
const ErrDashboardNotFound = "dashboard not found"
ErrDashboardNotFound is the error msg for a missing dashboard.
const ErrLabelNotFound = ChronografError("label not found")
ErrLabelNotFound is the error for a missing Label.
const ErrScraperTargetNotFound = "scraper target not found"
ErrScraperTargetNotFound is the error msg for a missing scraper target.
const ErrSessionExpired = "session has expired"
ErrSessionExpired is the error message for expired sessions.
const ErrSessionNotFound = "session not found"
ErrSessionNotFound is the error messages for a missing sessions.
const (
// ErrSourceNotFound is an error message when a source does not exist.
ErrSourceNotFound = "source not found"
)
const ErrTelegrafConfigInvalidOrganizationID = "invalid organization ID"
ErrTelegrafConfigInvalidOrganizationID is the error message for a missing or invalid organization ID.
const ErrViewNotFound = "view not found"
ErrViewNotFound is the error msg for a missing View.
const IDLength = 16
IDLength is the exact length a string (or a byte slice representing it) must have in order to be decoded into a valid ID.
const InfiniteRetention = 0
InfiniteRetention is default infinite retention period.
const (
// PrometheusScraperType parses metrics from a prometheus endpoint.
PrometheusScraperType = "prometheus"
)
Scraper types
Variables ¶
var ( // ErrAuthorizerNotSupported notes that the provided authorizer is not supported for the action you are trying to perform. ErrAuthorizerNotSupported = errors.New("your authorizer is not supported, please use *platform.Authorization as authorizer") // ErrInvalidResource notes that the provided resource is invalid ErrInvalidResource = errors.New("unknown resource for permission") // ErrInvalidAction notes that the provided action is invalid ErrInvalidAction = errors.New("unknown action for permission") )
var ( OpFindBucketByID = "FindBucketByID" OpFindBucket = "FindBucket" OpFindBuckets = "FindBuckets" OpCreateBucket = "CreateBucket" OpUpdateBucket = "UpdateBucket" OpDeleteBucket = "DeleteBucket" )
ops for buckets error and buckets op logs.
var ( // OpFindSession represents the operation that looks for sessions. OpFindSession = "FindSession" // OpExpireSession represents the operation that expires sessions. OpExpireSession = "ExpireSession" // OpCreateSession represents the operation that creates a session for a given user. OpCreateSession = "CreateSession" )
var ( OpFindTelegrafConfigByID = "FindTelegrafConfigByID" OpFindTelegrafConfig = "FindTelegrafConfig" OpFindTelegrafConfigs = "FindTelegrafConfigs" OpCreateTelegrafConfig = "CreateTelegrafConfig" OpUpdateTelegrafConfig = "UpdateTelegrafConfig" OpDeleteTelegrafConfig = "DeleteTelegrafConfig" )
ops for buckets error and buckets op logs.
var ( // ErrInvalidUserType notes that the provided UserType is invalid ErrInvalidUserType = errors.New("unknown user type") // ErrUserIDRequired notes that the ID was not provided ErrUserIDRequired = errors.New("user id is required") // ErrResourceIDRequired notes that the provided ID was not provided ErrResourceIDRequired = errors.New("resource id is required") )
var AllResources = []Resource{ AuthorizationsResource, BucketsResource, DashboardsResource, OrgsResource, SourcesResource, TasksResource, TelegrafsResource, UsersResource, }
AllResources is the list of all known resource types.
var DefaultDashboardFindOptions = FindOptions{
SortBy: "ID",
}
DefaultDashboardFindOptions are the default find options for dashboards
var DefaultOperationLogFindOptions = FindOptions{ Descending: true, Limit: 100, }
DefaultOperationLogFindOptions are the default options for the operation log.
var ErrInvalidID = errors.New("invalid ID")
ErrInvalidID signifies invalid IDs.
var ErrInvalidIDLength = errors.New("id must have a length of 16 bytes")
ErrInvalidIDLength is returned when an ID has the incorrect number of bytes.
var ( // ErrUnableToCreateToken sanitized error message for all errors when a user cannot create a token ErrUnableToCreateToken = &Error{ Msg: "unable to create token", Code: EInvalid, } )
var OrgResources = []Resource{ BucketsResource, DashboardsResource, SourcesResource, TasksResource, TelegrafsResource, UsersResource, }
OrgResources is the list of all known resource types that belong to an organization.
Functions ¶
func CreateMeasurement ¶
CreateMeasurement returns 16 bytes that represent a measurement.
If either org or bucket are short then an error is returned, otherwise the first 8 bytes of each are combined and returned.
func ErrorCode ¶
ErrorCode returns the code of the root error, if available; otherwise returns EINTERNAL.
func ErrorMessage ¶
ErrorMessage returns the human-readable message of the error, if available. Otherwise returns a generic error message.
func MarshalViewPropertiesJSON ¶
func MarshalViewPropertiesJSON(v ViewProperties) ([]byte, error)
MarshalViewPropertiesJSON encodes a view into JSON bytes.
func PermissionAllowed ¶
func PermissionAllowed(p Permission, ps []Permission) bool
PermissionAllowed
func ReadMeasurement ¶
ReadMeasurement reads the provided measurement name and returns an Org ID and bucket ID. It returns an error if the provided name has an invalid length.
ReadMeasurement does not allocate, and instead returns sub-slices of name, so callers should be careful about subsequent mutations to the provided name slice.
func SortDashboards ¶
SortDashboards sorts a slice of dashboards by a field.
func ValidScraperType ¶
ValidScraperType returns true is the type string is valid
func WithErrorCode ¶
WithErrorCode sets the code on the error.
func WithErrorErr ¶
WithErrorErr sets the err on the error.
func WithErrorMsg ¶
WithErrorMsg sets the message on the error.
func WithErrorOp ¶
WithErrorOp sets the message on the error.
Types ¶
type AddDashboardCellOptions ¶
type AddDashboardCellOptions struct {
View *View
}
AddDashboardCellOptions are options for adding a dashboard.
type Authorization ¶
type Authorization struct { ID ID `json:"id"` Token string `json:"token"` Status Status `json:"status"` Description string `json:"description"` OrgID ID `json:"orgID"` UserID ID `json:"userID"` Permissions []Permission `json:"permissions"` }
Authorization is an authorization. 🎉
func (*Authorization) Allowed ¶
func (a *Authorization) Allowed(p Permission) bool
Allowed returns true if the authorization is active and request permission exists in the authorization's list of permissions.
func (*Authorization) GetUserID ¶
func (a *Authorization) GetUserID() ID
GetUserID returns the user id.
func (*Authorization) Identifier ¶
func (a *Authorization) Identifier() ID
Identifier returns the authorizations ID and is used for auditing.
func (*Authorization) IsActive ¶
func (a *Authorization) IsActive() bool
IsActive returns true if the authorization active.
func (*Authorization) Kind ¶
func (a *Authorization) Kind() string
Kind returns session and is used for auditing.
type AuthorizationFilter ¶
AuthorizationFilter represents a set of filter that restrict the returned results.
type AuthorizationService ¶
type AuthorizationService interface { // Returns a single authorization by ID. FindAuthorizationByID(ctx context.Context, id ID) (*Authorization, error) // Returns a single authorization by Token. FindAuthorizationByToken(ctx context.Context, t string) (*Authorization, error) // Returns a list of authorizations that match filter and the total count of matching authorizations. // Additional options provide pagination & sorting. FindAuthorizations(ctx context.Context, filter AuthorizationFilter, opt ...FindOptions) ([]*Authorization, int, error) // Creates a new authorization and sets a.Token and a.UserID with the new identifier. CreateAuthorization(ctx context.Context, a *Authorization) error // SetAuthorizationStatus updates the status of the authorization. Useful // for setting an authorization to inactive or active. SetAuthorizationStatus(ctx context.Context, id ID, status Status) error // Removes a authorization by token. DeleteAuthorization(ctx context.Context, id ID) error }
AuthorizationService represents a service for managing authorization data.
type Authorizer ¶
type Authorizer interface { // Allowed returns true is the associated permission is allowed by the authorizer Allowed(p Permission) bool // ID returns an identifier used for auditing. Identifier() ID // GetUserID returns the user id. GetUserID() ID // Kind metadata for auditing. Kind() string }
Authorizer will authorize a permission.
type Axis ¶
type Axis struct { Bounds []string `json:"bounds"` // bounds are an arbitrary list of client-defined strings that specify the viewport for a View LegacyBounds [2]int64 `json:"-"` // legacy bounds are for testing a migration from an earlier version of axis Label string `json:"label"` // label is a description of this Axis Prefix string `json:"prefix"` // Prefix represents a label prefix for formatting axis values Suffix string `json:"suffix"` // Suffix represents a label suffix for formatting axis values Base string `json:"base"` // Base represents the radix for formatting axis values Scale string `json:"scale"` // Scale is the axis formatting scale. Supported: "log", "linear" }
Axis represents the visible extents of a visualization
type BasicAuthService ¶
type BasicAuthService interface { SetPassword(ctx context.Context, name string, password string) error ComparePassword(ctx context.Context, name string, password string) error CompareAndSetPassword(ctx context.Context, name string, old string, new string) error }
BasicAuthService is the service for managing basic auth.
type Bucket ¶
type Bucket struct { ID ID `json:"id,omitempty"` OrganizationID ID `json:"organizationID,omitempty"` Organization string `json:"organization,omitempty"` Name string `json:"name"` RetentionPolicyName string `json:"rp,omitempty"` // This to support v1 sources RetentionPeriod time.Duration `json:"retentionPeriod"` }
Bucket is a bucket. 🎉
type BucketFilter ¶
BucketFilter represents a set of filter that restrict the returned results.
func (BucketFilter) QueryParams ¶
func (f BucketFilter) QueryParams() map[string][]string
QueryParams Converts BucketFilter fields to url query params.
type BucketOperationLogService ¶
type BucketOperationLogService interface { // GetBucketOperationLog retrieves the operation log for the bucket with the provided id. GetBucketOperationLog(ctx context.Context, id ID, opts FindOptions) ([]*OperationLogEntry, int, error) }
BucketOperationLogService is an interface for retrieving the operation log for a bucket.
type BucketService ¶
type BucketService interface { // FindBucketByID returns a single bucket by ID. FindBucketByID(ctx context.Context, id ID) (*Bucket, error) // FindBucket returns the first bucket that matches filter. FindBucket(ctx context.Context, filter BucketFilter) (*Bucket, error) // FindBuckets returns a list of buckets that match filter and the total count of matching buckets. // Additional options provide pagination & sorting. FindBuckets(ctx context.Context, filter BucketFilter, opt ...FindOptions) ([]*Bucket, int, error) // CreateBucket creates a new bucket and sets b.ID with the new identifier. CreateBucket(ctx context.Context, b *Bucket) error // UpdateBucket updates a single bucket with changeset. // Returns the new bucket state after update. UpdateBucket(ctx context.Context, id ID, upd BucketUpdate) (*Bucket, error) // DeleteBucket removes a bucket by ID. DeleteBucket(ctx context.Context, id ID) error }
BucketService represents a service for managing bucket data.
type BucketUpdate ¶
type BucketUpdate struct { Name *string `json:"name,omitempty"` RetentionPeriod *time.Duration `json:"retentionPeriod,omitempty"` }
BucketUpdate represents updates to a bucket. Only fields which are set are updated.
type BuilderConfig ¶
type Cell ¶
type Cell struct { ID ID `json:"id,omitempty"` X int32 `json:"x"` Y int32 `json:"y"` W int32 `json:"w"` H int32 `json:"h"` }
Cell holds positional information about a cell on dashboard and a reference to a cell.
type CellUpdate ¶
type CellUpdate struct { X *int32 `json:"x"` Y *int32 `json:"y"` W *int32 `json:"w"` H *int32 `json:"h"` }
CellUpdate is the patch structure for a cell.
func (CellUpdate) Apply ¶
func (u CellUpdate) Apply(c *Cell) error
Apply applies an update to a Cell.
func (CellUpdate) Valid ¶
func (u CellUpdate) Valid() *Error
Valid returns an error if the cell update is invalid.
type ChronografError ¶
type ChronografError string
ChronografError is a domain error encountered while processing chronograf requests.
func (ChronografError) Error ¶
func (e ChronografError) Error() string
ChronografError returns the string of an error.
type DBRPMapping ¶
type DBRPMapping struct { Cluster string `json:"cluster"` Database string `json:"database"` RetentionPolicy string `json:"retention_policy"` // Default indicates if this mapping is the default for the cluster and database. Default bool `json:"default"` OrganizationID ID `json:"organization_id"` BucketID ID `json:"bucket_id"` }
DBRPMapping represents a mapping of a cluster, database and retention policy to an organization ID and bucket ID.
func (*DBRPMapping) Equal ¶
func (m *DBRPMapping) Equal(o *DBRPMapping) bool
Equal checks if the two mappings are identical.
func (DBRPMapping) Validate ¶
func (m DBRPMapping) Validate() error
Validate reports any validation errors for the mapping.
type DBRPMappingFilter ¶
type DBRPMappingFilter struct { Cluster *string Database *string RetentionPolicy *string Default *bool }
DBRPMappingFilter represents a set of filters that restrict the returned results by cluster, database and retention policy.
func (DBRPMappingFilter) String ¶
func (f DBRPMappingFilter) String() string
type DBRPMappingService ¶
type DBRPMappingService interface { // FindBy returns the dbrp mapping the for cluster, db and rp. FindBy(ctx context.Context, cluster, db, rp string) (*DBRPMapping, error) // Find returns the first dbrp mapping the matches the filter. Find(ctx context.Context, filter DBRPMappingFilter) (*DBRPMapping, error) // FindMany returns a list of dbrp mappings that match filter and the total count of matching dbrp mappings. FindMany(ctx context.Context, filter DBRPMappingFilter, opt ...FindOptions) ([]*DBRPMapping, int, error) // Create creates a new dbrp mapping, if a different mapping exists an error is returned. Create(ctx context.Context, dbrpMap *DBRPMapping) error // Delete removes a dbrp mapping. // Deleting a mapping that does not exists is not an error. Delete(ctx context.Context, cluster, db, rp string) error }
DBRPMappingService provides a mapping of cluster, database and retention policy to an organization ID and bucket ID.
type Dashboard ¶
type Dashboard struct { ID ID `json:"id,omitempty"` Name string `json:"name"` Description string `json:"description"` Cells []*Cell `json:"cells"` Meta DashboardMeta `json:"meta"` }
Dashboard represents all visual and query data for a dashboard.
type DashboardFilter ¶
type DashboardFilter struct {
IDs []*ID
}
DashboardFilter is a filter for dashboards.
type DashboardMeta ¶
type DashboardMeta struct { CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` }
DashboardMeta contains meta information about dashboards
type DashboardOperationLogService ¶
type DashboardOperationLogService interface { // GetDashboardOperationLog retrieves the operation log for the dashboard with the provided id. GetDashboardOperationLog(ctx context.Context, id ID, opts FindOptions) ([]*OperationLogEntry, int, error) }
DashboardOperationLogService is an interface for retrieving the operation log for a dashboard.
type DashboardQuery ¶
type DashboardQuery struct { Text string `json:"text"` Type string `json:"type"` SourceID string `json:"sourceID"` EditMode string `json:"editMode"` // Either "builder" or "advanced" Name string `json:"name"` // Term or phrase that refers to the query BuilderConfig BuilderConfig `json:"builderConfig"` }
DashboardQuery represents a query used in a dashboard cell
type DashboardService ¶
type DashboardService interface { // FindDashboardByID returns a single dashboard by ID. FindDashboardByID(ctx context.Context, id ID) (*Dashboard, error) // FindDashboards returns a list of dashboards that match filter and the total count of matching dashboards. // Additional options provide pagination & sorting. FindDashboards(ctx context.Context, filter DashboardFilter, opts FindOptions) ([]*Dashboard, int, error) // CreateDashboard creates a new dashboard and sets b.ID with the new identifier. CreateDashboard(ctx context.Context, b *Dashboard) error // UpdateDashboard updates a single dashboard with changeset. // Returns the new dashboard state after update. UpdateDashboard(ctx context.Context, id ID, upd DashboardUpdate) (*Dashboard, error) // AddDashboardCell adds a cell to a dashboard. AddDashboardCell(ctx context.Context, id ID, c *Cell, opts AddDashboardCellOptions) error // RemoveDashboardCell removes a dashbaord. RemoveDashboardCell(ctx context.Context, dashboardID, cellID ID) error // UpdateDashboardCell replaces the dashboard cell with the provided ID. UpdateDashboardCell(ctx context.Context, dashboardID, cellID ID, upd CellUpdate) (*Cell, error) // GetDashboardCellView retrieves a dashboard cells view. GetDashboardCellView(ctx context.Context, dashboardID, cellID ID) (*View, error) // UpdateDashboardCellView retrieves a dashboard cells view. UpdateDashboardCellView(ctx context.Context, dashboardID, cellID ID, upd ViewUpdate) (*View, error) // DeleteDashboard removes a dashboard by ID. DeleteDashboard(ctx context.Context, id ID) error // ReplaceDashboardCells replaces all cells in a dashboard ReplaceDashboardCells(ctx context.Context, id ID, c []*Cell) error }
DashboardService represents a service for managing dashboard data.
type DashboardUpdate ¶
DashboardUpdate is the patch structure for a dashboard.
func (DashboardUpdate) Apply ¶
func (u DashboardUpdate) Apply(d *Dashboard) error
Apply applies an update to a dashboard.
func (DashboardUpdate) Valid ¶
func (u DashboardUpdate) Valid() *Error
Valid returns an error if the dashboard update is invalid.
type DecimalPlaces ¶
DecimalPlaces indicates whether decimal places should be enforced, and how many digits it should show.
type EmptyViewProperties ¶
type EmptyViewProperties struct{}
EmptyViewProperties is visualization that has no values
func (EmptyViewProperties) GetType ¶
func (v EmptyViewProperties) GetType() string
type Error ¶
Error is the error struct of platform.
Errors may have error codes, human-readable messages, and a logical stack trace.
The Code targets automated handlers so that recovery can occur. Msg is used by the system operator to help diagnose and fix the problem. Op and Err chain errors together in a logical stack trace to further help operators.
To create a simple error,
&Error{ Code:ENotFound, }
To show where the error happens, add Op.
&Error{ Code: ENotFound, Op: "bolt.FindUserByID" }
To show an error with a unpredictable value, add the value in Msg.
&Error{ Code: EConflict, Message: fmt.Sprintf("organization with name %s already exist", aName), }
To show an error wrapped with another error.
&Error{ Code:EInternal, Err: err, }.
func (*Error) MarshalJSON ¶
MarshalJSON recursively marshals the stack of Err.
func (*Error) UnmarshalJSON ¶
UnmarshalJSON recursively unmarshals the error stack.
type FindOptions ¶
FindOptions represents options passed to all find methods with multiple results.
func (FindOptions) QueryParams ¶
func (f FindOptions) QueryParams() map[string][]string
QueryParams returns a map containing url query params.
type GaugeViewProperties ¶
type GaugeViewProperties struct { Type string `json:"type"` Queries []DashboardQuery `json:"queries"` Prefix string `json:"prefix"` Suffix string `json:"suffix"` ViewColors []ViewColor `json:"colors"` DecimalPlaces DecimalPlaces `json:"decimalPlaces"` Note string `json:"note"` ShowNoteWhenEmpty bool `json:"showNoteWhenEmpty"` }
GaugeViewProperties represents options for gauge view in Chronograf
func (GaugeViewProperties) GetType ¶
func (v GaugeViewProperties) GetType() string
type ID ¶
type ID uint64
ID is a unique identifier.
Its zero value is not a valid ID.
func IDFromString ¶
IDFromString creates an ID from a given string.
It errors if the input string does not match a valid ID.
func InternalBucketID ¶
func InternalBucketID(t BucketType) (*ID, error)
InternalBucketID returns the ID for an organization's specified internal bucket
func (*ID) Decode ¶
Decode parses b as a hex-encoded byte-slice-string.
It errors if the input byte slice does not have the correct length or if it contains all zeros.
func (*ID) DecodeFromString ¶
DecodeFromString parses s as a hex-encoded string.
func (ID) Encode ¶
Encode converts ID to a hex-encoded byte-slice-string.
It errors if the receiving ID holds its zero value.
func (ID) GoString ¶
GoString formats the ID the same as the String method. Without this, when using the %#v verb, an ID would be printed as a uint64, so you would see e.g. 0x2def021097c6000 instead of 02def021097c6000 (note the leading 0x, which means the former doesn't show up in searches for the latter).
func (ID) MarshalJSON ¶
MarshalJSON implements JSON marshaller for IDs.
func (ID) String ¶
String returns the ID as a hex encoded string.
Returns an empty string in the case the ID is invalid.
func (*ID) UnmarshalJSON ¶
UnmarshalJSON implements JSON unmarshaller for IDs.
type IDGenerator ¶
type IDGenerator interface { // ID creates unique byte slice ID. ID() ID }
IDGenerator represents a generator for IDs.
type KeyValueLog ¶
type KeyValueLog interface { // AddLogEntry adds an entry (v,t) to the log defined for the key k. AddLogEntry(ctx context.Context, k []byte, v []byte, t time.Time) error // ForEachLogEntry iterates through all the log entries at key k and applies the function fn for each record. ForEachLogEntry(ctx context.Context, k []byte, opts FindOptions, fn func(v []byte, t time.Time) error) error // FirstLogEntry is used to retrieve the first entry in the log at key k. FirstLogEntry(ctx context.Context, k []byte) ([]byte, time.Time, error) // LastLogEntry is used to retrieve the last entry in the log at key k. LastLogEntry(ctx context.Context, k []byte) ([]byte, time.Time, error) }
KeyValuleLog is a generic type logs key-value pairs. This interface is intended to be used to construct other higher-level log-like resources such as an oplog or audit log.
The idea is to create a log who values can be accessed at the key k: k -> [(v0,t0) (v1,t1) ... (vn,tn)]
Logs may be retrieved in ascending or descending time order and support limits and offsets.
Example ¶
package main import ( "context" "fmt" "time" "github.com/influxdata/platform" "github.com/influxdata/platform/bolt" ) func main() { c := bolt.NewClient() c.Path = "example.bolt" ctx := context.Background() if err := c.Open(ctx); err != nil { panic(err) } for i := 0; i < 10; i++ { if err := c.AddLogEntry(ctx, []byte("bucket_0_auditlog"), []byte(fmt.Sprintf("abc-%v", i)), time.Now()); err != nil { panic(err) } } opts := platform.FindOptions{Limit: 2, Offset: 1, Descending: false} if err := c.ForEachLogEntry(ctx, []byte("bucket_0_auditlog"), opts, func(v []byte, t time.Time) error { fmt.Println(t.UTC()) fmt.Println(string(v)) fmt.Println() return nil }); err != nil { panic(err) } v, t, err := c.LastLogEntry(ctx, []byte("bucket_0_auditlog")) if err != nil { panic(err) } fmt.Println(t.UTC()) fmt.Println(string(v)) fmt.Println() v, t, err = c.FirstLogEntry(ctx, []byte("bucket_0_auditlog")) if err != nil { panic(err) } fmt.Println(t.UTC()) fmt.Println(string(v)) fmt.Println() }
Output:
type Label ¶
type LabelFilter ¶
type LabelService ¶
type LabelService interface { // FindLabels returns a list of labels that match a filter FindLabels(ctx context.Context, filter LabelFilter, opt ...FindOptions) ([]*Label, error) // CreateLabel creates a new label CreateLabel(ctx context.Context, l *Label) error // UpdateLabel updates a label with a changeset. UpdateLabel(ctx context.Context, l *Label, upd LabelUpdate) (*Label, error) // DeleteLabel deletes a label DeleteLabel(ctx context.Context, l Label) error }
type LabelUpdate ¶
LabelUpdate represents a changeset for a label. Only fields which are set are updated.
type Legend ¶
type Legend struct { Type string `json:"type,omitempty"` Orientation string `json:"orientation,omitempty"` }
Legend represents the encoding of data into a legend
type LinePlusSingleStatProperties ¶
type LinePlusSingleStatProperties struct { Queries []DashboardQuery `json:"queries"` Axes map[string]Axis `json:"axes"` Type string `json:"type"` Legend Legend `json:"legend"` ViewColors []ViewColor `json:"colors"` Prefix string `json:"prefix"` Suffix string `json:"suffix"` DecimalPlaces DecimalPlaces `json:"decimalPlaces"` Note string `json:"note"` ShowNoteWhenEmpty bool `json:"showNoteWhenEmpty"` }
LinePlusSingleStatProperties represents options for line plus single stat view in Chronograf
func (LinePlusSingleStatProperties) GetType ¶
func (v LinePlusSingleStatProperties) GetType() string
type LogColumnSetting ¶
type LogColumnSetting struct { Type string `json:"type"` Value string `json:"value"` Name string `json:"name,omitempty"` }
LogColumnSetting represent the settings for a specific column of a Log Viewer.
type LogViewProperties ¶
type LogViewProperties struct { Type string `json:"type"` Columns []LogViewerColumn `json:"columns"` }
LogViewProperties represents options for log viewer in Chronograf.
func (LogViewProperties) GetType ¶
func (v LogViewProperties) GetType() string
type LogViewerColumn ¶
type LogViewerColumn struct { Name string `json:"name"` Position int32 `json:"position"` Settings []LogColumnSetting `json:"settings"` }
LogViewerColumn represents a specific column in a Log Viewer.
type LookupService ¶
type LookupService interface { // Name returns the name for the resource and ID. Name(ctx context.Context, resource Resource, id ID) (string, error) }
LookupService provides field lookup for the resource and ID.
type Macro ¶
type Macro struct { ID ID `json:"id,omitempty"` Name string `json:"name"` Selected []string `json:"selected"` Arguments *MacroArguments `json:"arguments"` }
A Macro describes a keyword that can be expanded into several possible values when used in an InfluxQL or Flux query
type MacroArguments ¶
type MacroArguments struct { Type string `json:"type"` // "constant", "map", or "query" Values interface{} `json:"values"` // either MacroQueryValues, MacroConstantValues, MacroMapValues }
A MacroArguments contains arguments used when expanding a Macro
func (*MacroArguments) UnmarshalJSON ¶
func (a *MacroArguments) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals json into a MacroArguments struct, using the `Type` field to assign the approriate struct to the `Values` field
type MacroConstantValues ¶
type MacroConstantValues []string
MacroConstantValues are the data for expanding a constants-based Macro
type MacroMapValues ¶
MacroMapValues are the data for expanding a map-based Macro
type MacroQueryValues ¶
type MacroQueryValues struct { Query string `json:"query"` Language string `json:"language"` // "influxql" or "flux" }
MacroQueryValues contains a query used when expanding a query-based Macro
type MacroService ¶
type MacroService interface { // FindMacro finds a single macro from the store by its ID FindMacroByID(ctx context.Context, id ID) (*Macro, error) // FindMacros returns all macros in the store FindMacros(ctx context.Context) ([]*Macro, error) // CreateMacro creates a new macro and assigns it an ID CreateMacro(ctx context.Context, m *Macro) error // UpdateMacro updates a single macro with a changeset UpdateMacro(ctx context.Context, id ID, update *MacroUpdate) (*Macro, error) // ReplaceMacro replaces a single macro ReplaceMacro(ctx context.Context, macro *Macro) error // DeleteMacro removes a macro from the store DeleteMacro(ctx context.Context, id ID) error }
MacroService describes a service for managing Macros
type MacroUpdate ¶
type MacroUpdate struct { Name string `json:"name"` Selected []string `json:"selected"` Arguments *MacroArguments `json:"arguments"` }
A MacroUpdate describes a set of changes that can be applied to a Macro
func (*MacroUpdate) Apply ¶
func (u *MacroUpdate) Apply(m *Macro) error
Apply applies non-zero fields from a MacroUpdate to a Macro
func (*MacroUpdate) Valid ¶
func (u *MacroUpdate) Valid() error
Valid returns an error if a Macro changeset is not valid
type MarkdownViewProperties ¶
func (MarkdownViewProperties) GetType ¶
func (v MarkdownViewProperties) GetType() string
type OnboardingRequest ¶
type OnboardingRequest struct { User string `json:"username"` Password string `json:"password"` Org string `json:"org"` Bucket string `json:"bucket"` RetentionPeriod uint `json:"retentionPeriodHrs,omitempty"` }
OnboardingRequest is the request to setup defaults.
type OnboardingResults ¶
type OnboardingResults struct { User *User `json:"user"` Org *Organization `json:"org"` Bucket *Bucket `json:"bucket"` Auth *Authorization `json:"auth"` }
OnboardingResults is a group of elements required for first run.
type OnboardingService ¶
type OnboardingService interface { BasicAuthService BucketService OrganizationService UserService AuthorizationService // IsOnboarding determine if onboarding request is allowed. IsOnboarding(ctx context.Context) (bool, error) // Generate OnboardingResults. Generate(ctx context.Context, req *OnboardingRequest) (*OnboardingResults, error) }
OnboardingService represents a service for the first run.
type OperationLogEntry ¶
type OperationLogEntry struct { Description string `json:"description"` UserID ID `json:"userID,omitempty"` Time time.Time `json:"time,omitempty"` }
OperationLogEntry is a record in an operation log.
type Organization ¶
Organization is an organization. 🎉
type OrganizationFilter ¶
OrganizationFilter represents a set of filter that restrict the returned results.
type OrganizationOperationLogService ¶
type OrganizationOperationLogService interface { // GetOrganizationOperationLog retrieves the operation log for the org with the provided id. GetOrganizationOperationLog(ctx context.Context, id ID, opts FindOptions) ([]*OperationLogEntry, int, error) }
OrganizationOperationLogService is an interface for retrieving the operation log for an org.
type OrganizationService ¶
type OrganizationService interface { // Returns a single organization by ID. FindOrganizationByID(ctx context.Context, id ID) (*Organization, error) // Returns the first organization that matches filter. FindOrganization(ctx context.Context, filter OrganizationFilter) (*Organization, error) // Returns a list of organizations that match filter and the total count of matching organizations. // Additional options provide pagination & sorting. FindOrganizations(ctx context.Context, filter OrganizationFilter, opt ...FindOptions) ([]*Organization, int, error) // Creates a new organization and sets b.ID with the new identifier. CreateOrganization(ctx context.Context, b *Organization) error // Updates a single organization with changeset. // Returns the new organization state after update. UpdateOrganization(ctx context.Context, id ID, upd OrganizationUpdate) (*Organization, error) // Removes a organization by ID. DeleteOrganization(ctx context.Context, id ID) error }
OrganizationService represents a service for managing organization data.
type OrganizationUpdate ¶
type OrganizationUpdate struct {
Name *string
}
OrganizationUpdate represents updates to a organization. Only fields which are set are updated.
type PagingFilter ¶
type PagingFilter interface { // QueryParams returns a map containing url query params. QueryParams() map[string][]string }
PagingFilter represents a filter containing url query params.
type PagingLinks ¶
type PagingLinks struct { Prev string `json:"prev,omitempty"` Self string `json:"self"` Next string `json:"next,omitempty"` }
PagingLinks represents paging links.
type Permission ¶
type Permission struct { Action Action `json:"action"` Resource Resource `json:"resource"` ID *ID `json:"id,omitempty"` }
Permission defines an action and a resource.
func NewPermission ¶
func NewPermission(a Action, r Resource) (*Permission, error)
NewPermission returns a permission with provided arguments.
func NewPermissionAtID ¶
func NewPermissionAtID(id ID, a Action, r Resource) (*Permission, error)
NewPermissionAtID creates a permission with the provided arguments.
func OperPermissions ¶
func OperPermissions() []Permission
OperPermissions are the default permissions for those who setup the application.
func OrgAdminPermissions ¶
func OrgAdminPermissions(orgID ID) []Permission
OrgAdminPermissions are the default permissions for org admins.
func OrgMemberPermissions ¶
func OrgMemberPermissions(orgID ID) []Permission
OrgMemberPermissions are the default permissions for org members.
func (Permission) String ¶
func (p Permission) String() string
func (*Permission) Valid ¶
func (p *Permission) Valid() error
Valid checks if there the resource and action provided is known.
type Proto ¶
type Proto struct { ID ID `json:"id"` Name string `json:"name"` Dashboards []ProtoDashboard `json:"dashboards,omitempty"` }
Proto is templated resource.
type ProtoDashboard ¶
type ProtoDashboard struct { Dashboard Dashboard `json:"dashboard"` Views map[ID]View `json:"views"` }
ProtoDashboard is a templated dashboard.
type ProtoService ¶
type ProtoService interface { // TODO(desa): add pagination here eventually. FindProtos(ctx context.Context) ([]*Proto, error) CreateDashboardsFromProto(ctx context.Context, protoID ID, orgID ID) ([]*Dashboard, error) }
ProtoService is what dashboard.land will be.
type RenamableField ¶
type RenamableField struct { InternalName string `json:"internalName"` DisplayName string `json:"displayName"` Visible bool `json:"visible"` }
RenamableField is a column/row field in a DashboardView of type Table
type Resource ¶
type Resource string
Resource is an enum defining all resources that have a permission model in platform
type Run ¶
type Run struct { ID ID `json:"id,omitempty"` TaskID ID `json:"taskID"` Status string `json:"status"` ScheduledFor string `json:"scheduledFor"` StartedAt string `json:"startedAt,omitempty"` FinishedAt string `json:"finishedAt,omitempty"` RequestedAt string `json:"requestedAt,omitempty"` Log Log `json:"log"` }
Run is a record created when a run of a task is scheduled.
type ScraperTarget ¶
type ScraperTarget struct { ID ID `json:"id,omitempty"` Name string `json:"name"` Type ScraperType `json:"type"` URL string `json:"url"` OrgName string `json:"org"` BucketName string `json:"bucket"` }
ScraperTarget is a target to scrape
type ScraperTargetFilter ¶
ScraperTargetFilter represents a set of filter that restrict the returned results.
type ScraperTargetStoreService ¶
type ScraperTargetStoreService interface { ListTargets(ctx context.Context) ([]ScraperTarget, error) AddTarget(ctx context.Context, t *ScraperTarget) error GetTargetByID(ctx context.Context, id ID) (*ScraperTarget, error) RemoveTarget(ctx context.Context, id ID) error UpdateTarget(ctx context.Context, t *ScraperTarget) (*ScraperTarget, error) }
ScraperTargetStoreService defines the crud service for ScraperTarget.
type SecretService ¶
type SecretService interface { // LoadSecret retrieves the secret value v found at key k for organization orgID. LoadSecret(ctx context.Context, orgID ID, k string) (string, error) // GetSecretKeys retrieves all secret keys that are stored for the organization orgID. GetSecretKeys(ctx context.Context, orgID ID) ([]string, error) // PutSecret stores the secret pair (k,v) for the organization orgID. PutSecret(ctx context.Context, orgID ID, k string, v string) error // PutSecrets puts all provided secrets and overwrites any previous values. PutSecrets(ctx context.Context, orgID ID, m map[string]string) error // PatchSecrets patches all provided secrets and updates any previous values. PatchSecrets(ctx context.Context, orgID ID, m map[string]string) error // DeleteSecret removes a single secret from the secret store. DeleteSecret(ctx context.Context, orgID ID, ks ...string) error }
SecretService a service for storing and retrieving secrets.
type Session ¶
type Session struct { // ID is only required for auditing purposes. ID ID `json:"id"` Key string `json:"key"` CreatedAt time.Time `json:"createdAt"` ExpiresAt time.Time `json:"expiresAt"` UserID ID `json:"userID,omitempty"` Permissions []Permission `json:"permissions,omitempty"` }
Session is a user session.
func (*Session) Allowed ¶
func (s *Session) Allowed(p Permission) bool
Allowed returns true if the authorization is unexpired and request permission exists in the sessions list of permissions.
func (*Session) Identifier ¶
Identifier returns the sessions ID and is used for auditing.
type SessionService ¶
type SessionService interface { FindSession(ctx context.Context, key string) (*Session, error) ExpireSession(ctx context.Context, key string) error CreateSession(ctx context.Context, user string) (*Session, error) }
SessionService represents a service for managing user sessions.
type SingleStatViewProperties ¶
type SingleStatViewProperties struct { Type string `json:"type"` Queries []DashboardQuery `json:"queries"` Prefix string `json:"prefix"` Suffix string `json:"suffix"` ViewColors []ViewColor `json:"colors"` DecimalPlaces DecimalPlaces `json:"decimalPlaces"` Note string `json:"note"` ShowNoteWhenEmpty bool `json:"showNoteWhenEmpty"` }
SingleStatViewProperties represents options for single stat view in Chronograf
func (SingleStatViewProperties) GetType ¶
func (v SingleStatViewProperties) GetType() string
type Source ¶
type Source struct { ID ID `json:"id,string,omitempty"` // ID is the unique ID of the source OrganizationID ID `json:"organizationID"` // OrganizationID is the organization ID that resource belongs to Default bool `json:"default"` // Default specifies the default source for the application Name string `json:"name"` // Name is the user-defined name for the source Type SourceType `json:"type,omitempty"` // Type specifies which kinds of source (enterprise vs oss vs 2.0) URL string `json:"url"` // URL are the connections to the source InsecureSkipVerify bool `json:"insecureSkipVerify,omitempty"` // InsecureSkipVerify as true means any certificate presented by the source is accepted Telegraf string `json:"telegraf"` // Telegraf is the db telegraf is written to. By default it is "telegraf" SourceFields V1SourceFields }
Source is an external Influx with time series data. TODO(desa): do we still need default? TODO(desa): do sources belong
type SourceFields ¶
type SourceFields struct {
Token string `json:"token"` // Token is the 2.0 authorization token associated with a source
}
SourceFields is used to authorize against an influx 2.0 source.
type SourceQuery ¶
SourceQuery is a query for a source.
type SourceService ¶
type SourceService interface { // DefaultSource retrieves the default source. DefaultSource(ctx context.Context) (*Source, error) // FindSourceByID retrieves a source by its ID. FindSourceByID(ctx context.Context, id ID) (*Source, error) // FindSources returns a list of all sources. FindSources(ctx context.Context, opts FindOptions) ([]*Source, int, error) // CreateSource sets the sources ID and stores it. CreateSource(ctx context.Context, s *Source) error // UpdateSource updates the source. UpdateSource(ctx context.Context, id ID, upd SourceUpdate) (*Source, error) // DeleteSource removes the source. DeleteSource(ctx context.Context, id ID) error }
SourceService is a service for managing sources.
type SourceUpdate ¶
type SourceUpdate struct { Name *string `json:"name"` Type *SourceType `json:"type,omitempty"` Token *string `json:"token"` URL *string `json:"url"` InsecureSkipVerify *bool `json:"insecureSkipVerify,omitempty"` Telegraf *string `json:"telegraf"` Username *string `json:"username,omitempty"` Password *string `json:"password,omitempty"` MetaURL *string `json:"metaURL,omitempty"` Role *string `json:"role,omitempty"` DefaultRP *string `json:"defaultRP"` }
SourceUpdate represents updates to a source.
func (SourceUpdate) Apply ¶
func (u SourceUpdate) Apply(s *Source) error
Apply applies an update to a source.
type TableOptions ¶
type TableOptions struct { VerticalTimeAxis bool `json:"verticalTimeAxis"` SortBy RenamableField `json:"sortBy"` Wrapping string `json:"wrapping"` FixFirstColumn bool `json:"fixFirstColumn"` }
TableOptions is a type of options for a DashboardView with type Table
type TableViewProperties ¶
type TableViewProperties struct { Type string `json:"type"` Queries []DashboardQuery `json:"queries"` ViewColors []ViewColor `json:"colors"` TableOptions TableOptions `json:"tableOptions"` FieldOptions []RenamableField `json:"fieldOptions"` TimeFormat string `json:"timeFormat"` DecimalPlaces DecimalPlaces `json:"decimalPlaces"` Note string `json:"note"` ShowNoteWhenEmpty bool `json:"showNoteWhenEmpty"` }
TableViewProperties represents options for table view in Chronograf
func (TableViewProperties) GetType ¶
func (v TableViewProperties) GetType() string
type Task ¶
type Task struct { ID ID `json:"id,omitempty"` Organization ID `json:"organizationID"` Name string `json:"name"` Status string `json:"status"` Owner User `json:"owner"` Flux string `json:"flux"` Every string `json:"every,omitempty"` Cron string `json:"cron,omitempty"` Offset string `json:"offset,omitempty"` LatestCompleted string `json:"latest_completed,omitempty"` }
Task is a task. 🎊
type TaskFilter ¶
TaskFilter represents a set of filters that restrict the returned results
type TaskService ¶
type TaskService interface { // FindTaskByID returns a single task FindTaskByID(ctx context.Context, id ID) (*Task, error) // FindTasks returns a list of tasks that match a filter (limit 100) and the total count // of matching tasks. FindTasks(ctx context.Context, filter TaskFilter) ([]*Task, int, error) // CreateTask creates a new task. CreateTask(ctx context.Context, t *Task) error // UpdateTask updates a single task with changeset. UpdateTask(ctx context.Context, id ID, upd TaskUpdate) (*Task, error) // DeleteTask removes a task by ID and purges all associated data and scheduled runs. DeleteTask(ctx context.Context, id ID) error // FindLogs returns logs for a run. FindLogs(ctx context.Context, filter LogFilter) ([]*Log, int, error) // FindRuns returns a list of runs that match a filter and the total count of returned runs. FindRuns(ctx context.Context, filter RunFilter) ([]*Run, int, error) // FindRunByID returns a single run. FindRunByID(ctx context.Context, taskID, runID ID) (*Run, error) // CancelRun cancels a currently running run. CancelRun(ctx context.Context, taskID, runID ID) error // RetryRun creates and returns a new run (which is a retry of another run). RetryRun(ctx context.Context, taskID, runID ID) (*Run, error) // ForceRun forces a run to occur with unix timestamp scheduledFor, to be executed as soon as possible. // The value of scheduledFor may or may not align with the task's schedule. ForceRun(ctx context.Context, taskID ID, scheduledFor int64) (*Run, error) }
TaskService represents a service for managing one-off and recurring tasks.
type TaskUpdate ¶
type TaskUpdate struct { Flux *string `json:"flux,omitempty"` Status *string `json:"status,omitempty"` }
TaskUpdate represents updates to a task
type TelegrafAgentConfig ¶
type TelegrafAgentConfig struct { // Interval at which to gather information in miliseconds. Interval int64 `json:"collectionInterval"` }
TelegrafAgentConfig is based telegraf/internal/config AgentConfig.
type TelegrafConfig ¶
type TelegrafConfig struct { ID ID OrganizationID ID Name string Agent TelegrafAgentConfig Plugins []TelegrafPlugin }
TelegrafConfig stores telegraf config for one telegraf instance.
func (*TelegrafConfig) MarshalJSON ¶
func (tc *TelegrafConfig) MarshalJSON() ([]byte, error)
MarshalJSON implement the json.Marshaler interface.
func (TelegrafConfig) TOML ¶
func (tc TelegrafConfig) TOML() string
TOML returns the telegraf toml config string.
func (*TelegrafConfig) UnmarshalJSON ¶
func (tc *TelegrafConfig) UnmarshalJSON(b []byte) error
UnmarshalJSON implement the json.Unmarshaler interface.
func (*TelegrafConfig) UnmarshalTOML ¶
func (tc *TelegrafConfig) UnmarshalTOML(data interface{}) error
UnmarshalTOML implements toml.Unmarshaler interface.
type TelegrafConfigFilter ¶
type TelegrafConfigFilter struct { OrganizationID *ID UserResourceMappingFilter }
TelegrafConfigFilter represents a set of filter that restrict the returned telegraf configs.
type TelegrafConfigStore ¶
type TelegrafConfigStore interface { // UserResourceMappingService must be part of all TelegrafConfigStore service, // for create, search, delete. UserResourceMappingService // FindTelegrafConfigByID returns a single telegraf config by ID. FindTelegrafConfigByID(ctx context.Context, id ID) (*TelegrafConfig, error) // FindTelegrafConfig returns the first telegraf config that matches filter. FindTelegrafConfig(ctx context.Context, filter TelegrafConfigFilter) (*TelegrafConfig, error) // FindTelegrafConfigs returns a list of telegraf configs that match filter and the total count of matching telegraf configs. // Additional options provide pagination & sorting. FindTelegrafConfigs(ctx context.Context, filter TelegrafConfigFilter, opt ...FindOptions) ([]*TelegrafConfig, int, error) // CreateTelegrafConfig creates a new telegraf config and sets b.ID with the new identifier. CreateTelegrafConfig(ctx context.Context, tc *TelegrafConfig, userID ID) error // UpdateTelegrafConfig updates a single telegraf config. // Returns the new telegraf config after update. UpdateTelegrafConfig(ctx context.Context, id ID, tc *TelegrafConfig, userID ID) (*TelegrafConfig, error) // DeleteTelegrafConfig removes a telegraf config by ID. DeleteTelegrafConfig(ctx context.Context, id ID) error }
TelegrafConfigStore represents a service for managing telegraf config data.
type TelegrafPlugin ¶
type TelegrafPlugin struct { Comment string `json:"comment"` Config plugins.Config `json:"config"` }
TelegrafPlugin is the general wrapper of the telegraf plugin config
type TokenGenerator ¶
TokenGenerator represents a generator for API tokens.
type Usage ¶
type Usage struct { OrganizationID *ID `json:"organizationID,omitempty"` BucketID *ID `json:"bucketID,omitempty"` Type UsageMetric `json:"type"` Value float64 `json:"value"` }
Usage is a metric associated with the utilization of a particular resource.
type UsageFilter ¶
UsageFilter is used to filter usage.
type UsageMetric ¶
type UsageMetric string
UsageMetric used to track classes of usage.
const ( // UsageWriteRequestCount is the name of the metrics for tracking write request count. UsageWriteRequestCount UsageMetric = "usage_write_request_count" // UsageWriteRequestBytes is the name of the metrics for tracking the number of write bytes. UsageWriteRequestBytes UsageMetric = "usage_write_request_bytes" // UsageValues is the name of the metrics for tracking the number of values. UsageValues UsageMetric = "usage_values" // UsageSeries is the name of the metrics for tracking the number of series written. UsageSeries UsageMetric = "usage_series" // UsageQueryRequestCount is the name of the metrics for tracking query request count. UsageQueryRequestCount UsageMetric = "usage_query_request_count" // UsageQueryRequestBytes is the name of the metrics for tracking the number of query bytes. UsageQueryRequestBytes UsageMetric = "usage_query_request_bytes" )
type UsageService ¶
type UsageService interface {
GetUsage(ctx context.Context, filter UsageFilter) (map[UsageMetric]*Usage, error)
}
UsageService is a service for accessing usage statistics.
type UserFilter ¶
UserFilter represents a set of filter that restrict the returned results.
type UserOperationLogService ¶
type UserOperationLogService interface { // GetUserOperationLog retrieves the operation log for the user with the provided id. GetUserOperationLog(ctx context.Context, id ID, opts FindOptions) ([]*OperationLogEntry, int, error) }
UserOperationLogService is an interface for retrieving the operation log for a user.
type UserResourceMapping ¶
type UserResourceMapping struct { UserID ID `json:"userID"` UserType UserType `json:"userType"` Resource Resource `json:"resource"` ResourceID ID `json:"resourceID"` }
UserResourceMapping represents a mapping of a resource to its user.
func (*UserResourceMapping) ToPermissions ¶
func (m *UserResourceMapping) ToPermissions() ([]Permission, error)
ToPermissions converts a user resource mapping into a set of permissions.
func (UserResourceMapping) Validate ¶
func (m UserResourceMapping) Validate() error
Validate reports any validation errors for the mapping.
type UserResourceMappingFilter ¶
type UserResourceMappingFilter struct { ResourceID ID Resource Resource UserID ID UserType UserType }
UserResourceMappingFilter represents a set of filters that restrict the returned results.
type UserResourceMappingService ¶
type UserResourceMappingService interface { // FindUserResourceMappings returns a list of UserResourceMappings that match filter and the total count of matching mappings. FindUserResourceMappings(ctx context.Context, filter UserResourceMappingFilter, opt ...FindOptions) ([]*UserResourceMapping, int, error) // CreateUserResourceMapping creates a user resource mapping. CreateUserResourceMapping(ctx context.Context, m *UserResourceMapping) error // DeleteUserResourceMapping deletes a user resource mapping. DeleteUserResourceMapping(ctx context.Context, resourceID ID, userID ID) error }
UserResourceMappingService maps the relationships between users and resources.
type UserService ¶
type UserService interface { // Returns a single user by ID. FindUserByID(ctx context.Context, id ID) (*User, error) // Returns the first user that matches filter. FindUser(ctx context.Context, filter UserFilter) (*User, error) // Returns a list of users that match filter and the total count of matching users. // Additional options provide pagination & sorting. FindUsers(ctx context.Context, filter UserFilter, opt ...FindOptions) ([]*User, int, error) // Creates a new user and sets u.ID with the new identifier. CreateUser(ctx context.Context, u *User) error // Updates a single user with changeset. // Returns the new user state after update. UpdateUser(ctx context.Context, id ID, upd UserUpdate) (*User, error) // Removes a user by ID. DeleteUser(ctx context.Context, id ID) error }
UserService represents a service for managing user data.
type UserUpdate ¶
type UserUpdate struct {
Name *string `json:"name"`
}
UserUpdate represents updates to a user. Only fields which are set are updated.
type V1SourceFields ¶
type V1SourceFields struct { Username string `json:"username,omitempty"` // Username is the username to connect to the source Password string `json:"password,omitempty"` // Password is in CLEARTEXT MetaURL string `json:"metaUrl,omitempty"` // MetaURL is the url for the meta node DefaultRP string `json:"defaultRP"` // DefaultRP is the default retention policy used in database queries to this source }
V1SourceFields are the fields for connecting to a 1.0 source (oss or enterprise)
type View ¶
type View struct { ViewContents Properties ViewProperties }
View holds positional and visual information for a View.
func (View) MarshalJSON ¶
MarshalJSON encodes a view to JSON bytes.
func (*View) UnmarshalJSON ¶
UnmarshalJSON decodes JSON bytes into the corresponding view type (those that implement ViewProperties).
type ViewColor ¶
type ViewColor struct { ID string `json:"id"` // ID is the unique id of the View color Type string `json:"type"` // Type is how the color is used. Accepted (min,max,threshold) Hex string `json:"hex"` // Hex is the hex number of the color Name string `json:"name"` // Name is the user-facing name of the hex color Value float64 `json:"value"` // Value is the data value mapped to this color }
ViewColor represents the encoding of data into visualizations
type ViewContents ¶
ViewContents is the id and name of a specific view.
type ViewContentsUpdate ¶
type ViewContentsUpdate struct {
Name *string `json:"name"`
}
ViewContentsUpdate is a struct for updating the non properties content of a View.
type ViewFilter ¶
ViewFilter represents a set of filter that restrict the returned results.
type ViewProperties ¶
type ViewProperties interface { GetType() string // contains filtered or unexported methods }
ViewProperties is used to mark other structures as conforming to a View.
func UnmarshalViewPropertiesJSON ¶
func UnmarshalViewPropertiesJSON(b []byte) (ViewProperties, error)
UnmarshalViewPropertiesJSON unmarshals JSON bytes into a ViewProperties.
type ViewService ¶
type ViewService interface { // FindViewByID returns a single View by ID. FindViewByID(ctx context.Context, id ID) (*View, error) // FindViews returns a list of Views that match filter and the total count of matching Views. // Additional options provide pagination & sorting. FindViews(ctx context.Context, filter ViewFilter) ([]*View, int, error) // CreateView creates a new View and sets b.ID with the new identifier. CreateView(ctx context.Context, b *View) error // UpdateView updates a single View with changeset. // Returns the new View state after update. UpdateView(ctx context.Context, id ID, upd ViewUpdate) (*View, error) // DeleteView removes a View by ID. DeleteView(ctx context.Context, id ID) error }
NOTE: This service has been DEPRECATED and should be removed. Views are now resources that are nested beneath dashboards.
ViewService represents a service for managing View data.
type ViewUpdate ¶
type ViewUpdate struct { ViewContentsUpdate Properties ViewProperties }
ViewUpdate is a struct for updating Views.
func (ViewUpdate) Apply ¶
func (u ViewUpdate) Apply(v *View) error
Apply updates a view with the view updates properties.
func (ViewUpdate) MarshalJSON ¶
func (u ViewUpdate) MarshalJSON() ([]byte, error)
MarshalJSON encodes a view to JSON bytes.
func (*ViewUpdate) UnmarshalJSON ¶
func (u *ViewUpdate) UnmarshalJSON(b []byte) error
UnmarshalJSON decodes JSON bytes into the corresponding view update type (those that implement ViewProperties).
func (ViewUpdate) Valid ¶
func (u ViewUpdate) Valid() *Error
Valid validates the update struct. It expects minimal values to be set.
type WriteService ¶
WriteService writes data read from the reader.
type XYViewProperties ¶
type XYViewProperties struct { Queries []DashboardQuery `json:"queries"` Axes map[string]Axis `json:"axes"` Type string `json:"type"` Legend Legend `json:"legend"` Geom string `json:"geom"` // Either "line", "step", "stacked", or "bar" ViewColors []ViewColor `json:"colors"` Note string `json:"note"` ShowNoteWhenEmpty bool `json:"showNoteWhenEmpty"` }
XYViewProperties represents options for line, bar, step, or stacked view in Chronograf
func (XYViewProperties) GetType ¶
func (v XYViewProperties) GetType() string
Source Files ¶
- auth.go
- authz.go
- bucket.go
- dashboard.go
- dbrp_mapping.go
- error.go
- errors.go
- id.go
- keyvalue_log.go
- label.go
- lookup.go
- macro.go
- measurement.go
- onboarding.go
- operation_log.go
- organization.go
- paging.go
- proto.go
- query.go
- scraper.go
- secret.go
- session.go
- source.go
- status.go
- task.go
- telegraf.go
- token.go
- usage.go
- user.go
- user_resource_mapping.go
- view.go
- write.go
Directories ¶
Path | Synopsis |
---|---|
oauth2
Package oauth2 provides http.Handlers necessary for implementing Oauth2 authentication with multiple Providers.
|
Package oauth2 provides http.Handlers necessary for implementing Oauth2 authentication with multiple Providers. |
cmd
|
|
influx_inspect/buildtsi
Package buildtsi reads an in-memory index and exports it as a TSI index.
|
Package buildtsi reads an in-memory index and exports it as a TSI index. |
NOTE: This service has been deprecated and should not be used.
|
NOTE: This service has been deprecated and should not be used. |
internal
|
|
kit
|
|
check
Package check standardizes /health and /ready endpoints.
|
Package check standardizes /health and /ready endpoints. |
cli
Package cli creates simple CLI options with ENV overrides using viper.
|
Package cli creates simple CLI options with ENV overrides using viper. |
prom
Package prom provides a wrapper around a prometheus metrics registry so that all services are unified in how they expose prometheus metrics.
|
Package prom provides a wrapper around a prometheus metrics registry so that all services are unified in how they expose prometheus metrics. |
prom/promtest
Package promtest provides helpers for parsing and extracting prometheus metrics.
|
Package promtest provides helpers for parsing and extracting prometheus metrics. |
Note: this file is used as a proof of concept for having a generic keyvalue store backed by specific implementations of kv.Store.
|
Note: this file is used as a proof of concept for having a generic keyvalue store backed by specific implementations of kv.Store. |
Package models implements basic objects used throughout the TICK stack.
|
Package models implements basic objects used throughout the TICK stack. |
pkg
|
|
deep
Package deep provides a deep equality check for use in tests.
|
Package deep provides a deep equality check for use in tests. |
encoding/simple8b
Package simple8b implements the 64bit integer encoding algoritm as published by Ann and Moffat in "Index compression using 64-bit words", Softw.
|
Package simple8b implements the 64bit integer encoding algoritm as published by Ann and Moffat in "Index compression using 64-bit words", Softw. |
escape
Package escape contains utilities for escaping parts of InfluxQL and InfluxDB line protocol.
|
Package escape contains utilities for escaping parts of InfluxQL and InfluxDB line protocol. |
estimator/hll
Package hll contains a HyperLogLog++ with a LogLog-Beta bias correction implementation that is adapted (mostly copied) from an implementation provided by Clark DuVall github.com/clarkduvall/hyperloglog.
|
Package hll contains a HyperLogLog++ with a LogLog-Beta bias correction implementation that is adapted (mostly copied) from an implementation provided by Clark DuVall github.com/clarkduvall/hyperloglog. |
limiter
Package limiter provides concurrency limiters.
|
Package limiter provides concurrency limiters. |
metrics
Package metrics provides various measurements that are safe for concurrent access.
|
Package metrics provides various measurements that are safe for concurrent access. |
mmap
Package mmap provides a way to memory-map a file.
|
Package mmap provides a way to memory-map a file. |
pool
Package pool provides pool structures to help reduce garbage collector pressure.
|
Package pool provides pool structures to help reduce garbage collector pressure. |
slices
Package slices contains functions to operate on slices treated as sets.
|
Package slices contains functions to operate on slices treated as sets. |
testing/assert
Package assert provides helper functions that can be used with the standard Go testing package.
|
Package assert provides helper functions that can be used with the standard Go testing package. |
builtin
Package builtin ensures all packages related to Flux built-ins are imported and initialized.
|
Package builtin ensures all packages related to Flux built-ins are imported and initialized. |
control
Package control provides a query controller.
|
Package control provides a query controller. |
functions/inputs/storage
Package storage implements reading from a storage engine into a table as a data source.
|
Package storage implements reading from a storage engine into a table as a data source. |
influxql
Package influxql implements the transpiler for executing influxql queries in the 2.0 query engine.
|
Package influxql implements the transpiler for executing influxql queries in the 2.0 query engine. |
influxql/spectests
Package spectests the influxql transpiler specification tests.
|
Package spectests the influxql transpiler specification tests. |
options
Package options implements flux options.
|
Package options implements flux options. |
promql
Package promql implements a promql parser to build flux query specifications from promql.
|
Package promql implements a promql parser to build flux query specifications from promql. |
compat
package compat helps with migrating toml files from influxdb.
|
package compat helps with migrating toml files from influxdb. |
backend/bolt
Package bolt provides an bolt-backed store implementation.
|
Package bolt provides an bolt-backed store implementation. |
backend/executor
Package executor contains implementations of backend.Executor that depend on the query service.
|
Package executor contains implementations of backend.Executor that depend on the query service. |
mock
Package mock contains mock implementations of different task interfaces.
|
Package mock contains mock implementations of different task interfaces. |
options
Package options provides ways to extract the task-related options from a Flux script.
|
Package options provides ways to extract the task-related options from a Flux script. |
servicetest
Package servicetest provides tests to ensure that implementations of platform/task/backend.Store and platform/task/backend.LogReader meet the requirements of platform.TaskService.
|
Package servicetest provides tests to ensure that implementations of platform/task/backend.Store and platform/task/backend.LogReader meet the requirements of platform.TaskService. |
telegraf
|
|
Package toml adds support to marshal and unmarshal types not in the official TOML spec.
|
Package toml adds support to marshal and unmarshal types not in the official TOML spec. |
tools
|
|
tsi1
Package tsi1 provides a memory-mapped index implementation that supports high cardinality series.
|
Package tsi1 provides a memory-mapped index implementation that supports high cardinality series. |
tsm1
Package tsm1 provides a TSDB in the Time Structured Merge tree format.
|
Package tsm1 provides a TSDB in the Time Structured Merge tree format. |
Package uuid provides functions to create time-based UUIDs.
|
Package uuid provides functions to create time-based UUIDs. |