Documentation ¶
Overview ¶
Package honeycombio provides a client to interact with the Honeycomb API.
Documentation of the API can be found here: https://docs.honeycomb.io/api/
Example ¶
This example shows how to configure and use a client to list all boards.
apiKey, _ := os.LookupEnv("HONEYCOMBIO_APIKEY") config := &Config{ APIKey: apiKey, } client, err := NewClient(config) if err != nil { panic(err) } ctx := context.Background() boards, err := client.Boards.List(ctx) if err != nil { panic(err) } fmt.Printf("Found %d boards\n", len(boards)) for i, board := range boards { fmt.Printf("%d| %s (%d queries)\n", i, board.Name, len(board.Queries)) }
Output:
Index ¶
- Variables
- func BoolPtr(v bool) *bool
- func Int64Ptr(v int64) *int64
- func IntPtr(v int) *int
- func MatchesTriggerSubset(query *QuerySpec) error
- func StringPtr(v string) *string
- type Board
- type BoardQuery
- type BoardQueryStyle
- type BoardStyle
- type Boards
- type CalculationOp
- type CalculationSpec
- type Client
- type Column
- type ColumnType
- type Columns
- type Config
- type Dataset
- type Datasets
- type DerivedColumn
- type DerivedColumns
- type FilterCombination
- type FilterOp
- type FilterSpec
- type Marker
- type Markers
- type OrderSpec
- type Queries
- type QueryAnnotation
- type QueryAnnotations
- type QuerySpec
- type SortOrder
- type Trigger
- type TriggerRecipient
- type TriggerRecipientType
- type TriggerThreshold
- type TriggerThresholdOp
- type Triggers
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("404 Not Found")
ErrNotFound is returned when the requested item could not be found.
Functions ¶
func MatchesTriggerSubset ¶ added in v0.0.11
MatchesTriggerSubset checks that the given QuerySpec matches the strict subset required to be used in a trigger.
The following properties must be valid:
- the query must contain exactly one calculation
- the HEATMAP calculation may not be used
- only the following fields may be set: calculations, breakdown, filters, filter_combination and time_range
For more information, refer to https://docs.honeycomb.io/api/triggers/#fields-on-a-trigger
Types ¶
type Board ¶ added in v0.0.6
type Board struct { ID string `json:"id,omitempty"` // Name of the board, this is displayed in the Honeycomb UI. This field is // required. Name string `json:"name"` // Description of the board. Description string `json:"description,omitempty"` // How the board should be displayed in the UI, defaults to "list". Style BoardStyle `json:"style,omitempty"` // A list of queries displayed on the board, in order of appearance. Queries []BoardQuery `json:"queries"` }
Board represents a Honeycomb board.
API docs: https://docs.honeycomb.io/api/boards-api/#fields-on-a-board
type BoardQuery ¶ added in v0.0.6
type BoardQuery struct { Caption string `json:"caption,omitempty"` // Defaults to graph. QueryStyle BoardQueryStyle `json:"query_style,omitempty"` // This field is required. Dataset string `json:"dataset"` // Either QueryID or Query is required. QueryID string `json:"query_id,omitempty"` Query *QuerySpec `json:"query,omitempty"` // Optional QueryAnnotationID string `json:"query_annotation_id,omitempty"` }
BoardQuery represents a query that is part of a board.
type BoardQueryStyle ¶ added in v0.1.3
type BoardQueryStyle string
BoardQueryStyle determines how a query should be displayed on the board.
const ( BoardQueryStyleGraph BoardQueryStyle = "graph" BoardQueryStyleTable BoardQueryStyle = "table" BoardQueryStyleCombo BoardQueryStyle = "combo" )
Declaration of board query styles.
func BoardQueryStyles ¶ added in v0.1.3
func BoardQueryStyles() []BoardQueryStyle
BoardQueryStyles returns an exhaustive list of board query styles.
type BoardStyle ¶ added in v0.0.6
type BoardStyle string
BoardStyle determines how a Board should be displayed within the Honeycomb UI.
const ( BoardStyleList BoardStyle = "list" BoardStyleVisual BoardStyle = "visual" )
Declaration of board styles.
func BoardStyles ¶ added in v0.1.0
func BoardStyles() []BoardStyle
BoardStyles returns an exhaustive list of board styles.
type Boards ¶ added in v0.0.6
type Boards interface { // List all boards. List(ctx context.Context) ([]Board, error) // Get a board by its ID. Returns ErrNotFound if there is no board with the // given ID. Get(ctx context.Context, id string) (*Board, error) // Create a new board. When creating a new board ID may not be set. Create(ctx context.Context, b *Board) (*Board, error) // Update an existing board. Update(ctx context.Context, b *Board) (*Board, error) // Delete a board. Delete(ctx context.Context, id string) error }
Boards describes all the board-related methods that the Honeycomb API supports.
type CalculationOp ¶ added in v0.0.5
type CalculationOp string
CalculationOp represents the operator of a calculation.
const ( CalculationOpCount CalculationOp = "COUNT" CalculationOpSum CalculationOp = "SUM" CalculationOpAvg CalculationOp = "AVG" CalculationOpCountDistinct CalculationOp = "COUNT_DISTINCT" CalculationOpMax CalculationOp = "MAX" CalculationOpMin CalculationOp = "MIN" CalculationOpP001 CalculationOp = "P001" CalculationOpP01 CalculationOp = "P01" CalculationOpP05 CalculationOp = "P05" CalculationOpP10 CalculationOp = "P10" CalculationOpP25 CalculationOp = "P25" CalculationOpP50 CalculationOp = "P50" CalculationOpP75 CalculationOp = "P75" CalculationOpP90 CalculationOp = "P90" CalculationOpP95 CalculationOp = "P95" CalculationOpP99 CalculationOp = "P99" CalculationOpP999 CalculationOp = "P999" CalculationOpHeatmap CalculationOp = "HEATMAP" )
Declaration of calculation operators.
func CalculationOpPtr ¶ added in v0.1.0
func CalculationOpPtr(v CalculationOp) *CalculationOp
CalculationOpPtr returns a pointer to the given CalculationOp.
func CalculationOps ¶ added in v0.1.0
func CalculationOps() []CalculationOp
CalculationOps returns an exhaustive list of calculation operators.
type CalculationSpec ¶ added in v0.0.5
type CalculationSpec struct { Op CalculationOp `json:"op"` // Column to perform the operation on. Not needed with COUNT. Column *string `json:"column,omitempty"` }
CalculationSpec represents a calculation within a query.
type Client ¶
type Client struct { Boards Boards Columns Columns Datasets Datasets DerivedColumns DerivedColumns Markers Markers Queries Queries QueryAnnotations QueryAnnotations Triggers Triggers // contains filtered or unexported fields }
Client to interact with Honeycomb.
type Column ¶ added in v0.2.1
type Column struct { ID string `json:"id,omitempty"` // Name of the column, this field is required. KeyName string `json:"key_name"` // Deprecated, optional. Alias string `json:"alias,omitempty"` // Optional, defaults to false. Hidden *bool `json:"hidden,omitempty"` // Optional. Description string `json:"description,omitempty"` // Optional, defaults to string. Type *ColumnType `json:"type,omitempty"` }
Column represents a Honeycomb column in a dataset.
API docs: https://docs.honeycomb.io/api/columns/#fields-on-a-column
type ColumnType ¶ added in v0.2.1
type ColumnType string
ColumnType determines the type of column.
const ( ColumnTypeString ColumnType = "string" ColumnTypeFloat ColumnType = "float" ColumnTypeInteger ColumnType = "integer" ColumnTypeBoolean ColumnType = "boolean" )
Declaration of column types.
func ColumnTypePtr ¶ added in v0.2.1
func ColumnTypePtr(v ColumnType) *ColumnType
ColumnTypePtr returns a pointer to the given ColumnType.
func ColumnTypes ¶ added in v0.2.1
func ColumnTypes() []ColumnType
ColumnTypes returns an exhaustive list of column types.
type Columns ¶ added in v0.2.1
type Columns interface { // List all columns in this dataset. List(ctx context.Context, dataset string) ([]Column, error) // Get a column by its ID. Returns ErrNotFound if there is no column with // the given ID in this dataset. Get(ctx context.Context, dataset string, id string) (*Column, error) // GetByKeyName searches a column by its key name. Returns ErrNotFound if // there is no column with the given key name in this dataset. GetByKeyName(ctx context.Context, dataset string, keyName string) (*Column, error) // Create a new column in this dataset. When creating a new column ID may // not be set. The KeyName must be unique for this dataset. Create(ctx context.Context, dataset string, c *Column) (*Column, error) // Update an existing column. Update(ctx context.Context, dataset string, c *Column) (*Column, error) // Delete a column. Delete(ctx context.Context, dataset string, id string) error }
Columns describe all the columns-related methods that the Honeycomb API supports.
API docs: https://docs.honeycomb.io/api/columns/
type Config ¶ added in v0.0.6
type Config struct { // Required - the API key to use when sending request to Honeycomb. APIKey string // URL of the Honeycomb API, defaults to "https://api.honeycomb.io". APIUrl string // User agent to send with all requests, defaults to "go-honeycombio". UserAgent string // With debug enabled the client will log all requests and responses. Debug bool }
Config holds all configuration options for the client.
type Dataset ¶ added in v0.2.1
Dataset represents a Honeycomb dataset.
API docs: https://docs.honeycomb.io/api/dataset
type Datasets ¶ added in v0.2.1
type Datasets interface { // List all datasets. List(ctx context.Context) ([]Dataset, error) // Get a dataset by its slug. Returns ErrNotFound if there is no dataset // with the given slug. Get(ctx context.Context, slug string) (*Dataset, error) // Create a new dataset. Only name should be set when creating a dataset, // all other fields are ignored. Create(ctx context.Context, dataset *Dataset) (*Dataset, error) }
Datasets describes all the dataset-related methods that the Honeycomb API supports.
API docs: https://docs.honeycomb.io/api/datasets/
type DerivedColumn ¶ added in v0.2.1
type DerivedColumn struct { ID string `json:"id,omitempty"` // Alias of the derived column, this field is required and can not be // updated. Alias string `json:"alias"` // Expression of the derived column, this field is required and can not be // updated. // This should be an expression following the Derived Column syntax, as // described on https://docs.honeycomb.io/working-with-your-data/customizing-your-query/derived-columns/#derived-column-syntax Expression string `json:"expression"` // Optional. Description string `json:"description,omitempty"` }
Column represents a Honeycomb derived column in a dataset.
API docs: https://docs.honeycomb.io/api/derived_columns/#fields-on-a-derivedcolumn
type DerivedColumns ¶ added in v0.2.1
type DerivedColumns interface { // List all derived columns in this dataset. List(ctx context.Context, dataset string) ([]DerivedColumn, error) // Get a derived column by its ID. Returns ErrNotFound if there is no // derived column with the given ID in this dataset. Get(ctx context.Context, dataset string, id string) (*DerivedColumn, error) // GetByAlias searches a derived column by its alias. Returns ErrNotFound if // there is no derived column with the given alias in this dataset. GetByAlias(ctx context.Context, dataset string, alias string) (*DerivedColumn, error) // Create a new derived column in this dataset. When creating a new derived // column ID may not be set. The Alias must be unique for this dataset. Create(ctx context.Context, dataset string, d *DerivedColumn) (*DerivedColumn, error) // Update an existing derived column. Update(ctx context.Context, dataset string, d *DerivedColumn) (*DerivedColumn, error) // Delete a derived column. Delete(ctx context.Context, dataset string, id string) error }
DerivedColumns describe all the derived columns-related methods that the Honeycomb API supports.
type FilterCombination ¶ added in v0.0.5
type FilterCombination string
FilterCombination describes how the filters of a query should be combined.
const ( FilterCombinationOr FilterCombination = "OR" FilterCombinationAnd FilterCombination = "AND" )
Declaration of filter combinations.
func FilterCombinations ¶ added in v0.1.0
func FilterCombinations() []FilterCombination
FilterCombinations returns an exhaustive list of filter combinations.
type FilterOp ¶ added in v0.0.5
type FilterOp string
FilterOp represents the operator of a filter.
const ( FilterOpEquals FilterOp = "=" FilterOpNotEquals FilterOp = "!=" FilterOpGreaterThan FilterOp = ">" FilterOpGreaterThanOrEqual FilterOp = ">=" FilterOpSmallerThan FilterOp = "<" FilterOpSmallerThanOrEqual FilterOp = "<=" FilterOpStartsWith FilterOp = "starts-with" FilterOpDoesNotStartWith FilterOp = "does-not-start-with" FilterOpExists FilterOp = "exists" FilterOpDoesNotExist FilterOp = "does-not-exist" FilterOpContains FilterOp = "contains" FilterOpDoesNotContain FilterOp = "does-not-contain" FilterOpIn FilterOp = "in" FilterOpNotIn FilterOp = "not-in" )
Declaration of filter operators.
type FilterSpec ¶ added in v0.0.5
type FilterSpec struct { Column string `json:"column"` Op FilterOp `json:"op"` // Value to use with the filter operation. The type of the filter value // depends on the operator: // - 'exists' and 'does-not-exist': value should be nil // - 'in' and 'not-in': value should be a []string // - all other ops: value should be a string Value interface{} `json:"value,omitempty"` }
FilterSpec represents a filter within a query.
type Marker ¶
type Marker struct { ID string `json:"id,omitempty"` // The time the marker should be placed at, in Unix Time (= seconds since // epoch). If not set this will be set to when the request was received by // the API. StartTime int64 `json:"start_time,omitempty"` // The end time of the marker, in Unix Time (= seconds since epoch). This // can be used to indicate a time range. This field is optional. EndTime int64 `json:"end_time,omitempty"` // Message appears above the marker and can be used to desribe the marker. // This field is optional. Message string `json:"message,omitempty"` // Type is an optional marker identifier, eg 'deploy' or 'chef-run'. This // field is optional. Type string `json:"type,omitempty"` // URL is an optional url associated with the marker. This field is optional. URL string `json:"url,omitempty"` // Time the marker was created. This field is set by the API. CreatedAt *time.Time `json:"created_at,omitempty"` // Time the marker was last modified. This field is set by the API. UpdatedAt *time.Time `json:"updated_at,omitempty"` // Color of the marker. Colors are configured per dataset and can be set // per type of marker. This field is set by the API. Color string `json:"color,omitempty"` }
Marker represents a Honeycomb marker.
API docs: https://docs.honeycomb.io/api/markers/#fields-on-a-marker
type Markers ¶
type Markers interface { // List all markers present in this dataset. List(ctx context.Context, dataset string) ([]Marker, error) // Get a marker by its ID. Returns ErrNotFound if there is no marker with // the given ID in this dataset. // // This method calls List internally since there is no API available to // directly get a single marker. Get(ctx context.Context, dataset string, id string) (*Marker, error) // Create a new marker in this dataset. When creating a marker ID may not // be set. Create(ctx context.Context, dataset string, m *Marker) (*Marker, error) // Update an existing marker. Update(ctx context.Context, dataset string, m *Marker) (*Marker, error) // Delete a marker from the dataset. Delete(ctx context.Context, dataset string, id string) error }
Markers describes all the marker-related methods that the Honeycomb API supports.
API docs: https://docs.honeycomb.io/api/markers/
type OrderSpec ¶ added in v0.0.11
type OrderSpec struct { Op *CalculationOp `json:"op,omitempty"` Column *string `json:"column,omitempty"` Order *SortOrder `json:"order,omitempty"` }
OrderSpec describes how to order the results of a query.
type Queries ¶ added in v0.2.2
type Queries interface { // Get a query by its ID. Get(ctx context.Context, dataset string, id string) (*QuerySpec, error) // Create a new query in this dataset. When creating a new query ID may // not be set. Create(ctx context.Context, dataset string, c *QuerySpec) (*QuerySpec, error) }
Queries describe all the query-related methods that the Honeycomb API supports.
API docs: https://docs.honeycomb.io/api/queries/
type QueryAnnotation ¶ added in v0.2.2
type QueryAnnotation struct { ID string `json:"id,omitempty"` Name string `json:"name"` Description string `json:"description"` QueryID string `json:"query_id"` CreatedAt *time.Time `json:"created-at,omitempty"` UpdatedAt *time.Time `json:"updated-at,omitempty"` }
QueryAnnotation represents a Honeycomb query annotation.
API docs: https://docs.honeycomb.io/api/query-annotations/#fields-on-a-query-annotation
type QueryAnnotations ¶ added in v0.2.2
type QueryAnnotations interface { // List all query annotations. List(ctx context.Context, dataset string) ([]QueryAnnotation, error) // Get a query annotation by its ID. Returns ErrNotFound if there is no // query annotation with the given ID. Get(ctx context.Context, dataset string, id string) (*QueryAnnotation, error) // Create a new query annotation. When creating a new query annotation ID // may not be set. Create(ctx context.Context, dataset string, b *QueryAnnotation) (*QueryAnnotation, error) // Update an existing query annotation. Update(ctx context.Context, dataset string, b *QueryAnnotation) (*QueryAnnotation, error) // Delete a query annotation. Delete(ctx context.Context, dataset string, id string) error }
QueryAnnotations describes all the query annotation-related methods that the Honeycomb API supports.
type QuerySpec ¶ added in v0.0.5
type QuerySpec struct { // ID of a query is only set when QuerySpec is returned from the Queries // API. This value should not be set when creating or updating queries. ID *string `json:"id,omitempty"` // The calculations to return as a time series and summary table. If no // calculations are provided, COUNT is applied. Calculations []CalculationSpec `json:"calculations,omitempty"` // The filters with which to restrict the considered events. Filters []FilterSpec `json:"filters,omitempty"` // If multiple filters are specified, filter_combination determines how // they are applied. Defaults to AND. // // From experience it seems the API will never answer with AND, instead // always omitting the filter combination field entirely. FilterCombination FilterCombination `json:"filter_combination,omitempty"` // A list of strings describing the columns by which to break events down // into groups. Breakdowns []string `json:"breakdowns,omitempty"` // A list of objects describing the terms on which to order the query // results. Each term must appear in either the breakdowns field or the // calculations field. Orders []OrderSpec `json:"orders,omitempty"` // The maximum number of query results, must be between 1 and 1000. Limit *int `json:"limit,omitempty"` // The time range of query in seconds. Defaults to two hours. If combined // with start time or end time, this time range is added after start time // or before end time. Cannot be combined with both start time and end time. // // For more details, check https://docs.honeycomb.io/api/query-specification/#a-caveat-on-time TimeRange *int `json:"time_range,omitempty"` // The absolute start time of the query, in Unix Time (= seconds since epoch). StartTime *int64 `json:"start_time,omitempty"` // The absolute end time of the query, in Unix Time (= seconds since epoch). EndTime *int64 `json:"end_time,omitempty"` // The time resolution of the query’s graph, in seconds. Valid values are // the query’s time range /10 at maximum, and /1000 at minimum. Granularity *int `json:"granularity,omitempty"` }
QuerySpec represents a Honeycomb query.
API docs: https://docs.honeycomb.io/api/query-specification/
type SortOrder ¶ added in v0.0.11
type SortOrder string
SortOrder describes in which order the results should be sorted.
Declaration of sort orders.
func SortOrderPtr ¶ added in v0.1.0
SortOrderPtr returns a pointer to the given SortOrder.
func SortOrders ¶ added in v0.1.0
func SortOrders() []SortOrder
SortOrders returns an exhaustive list of all sort orders.
type Trigger ¶ added in v0.0.5
type Trigger struct { ID string `json:"id,omitempty"` // Name of the trigger. This field is required. Name string `json:"name"` // Description is displayed on the triggers page. Description string `json:"description,omitempty"` // State of the trigger, if disabled is true the trigger will not run. Disabled bool `json:"disabled,omitempty"` // Query of the trigger. This field is required. The query must respect the // properties described with and validated by MatchesTriggerSubset. // Additionally, time_range of the query can be at most 1 day and may not // be greater than 4 times the frequency. Query *QuerySpec `json:"query"` // Threshold. This fild is required. Threshold *TriggerThreshold `json:"threshold"` // Frequency describes how often the trigger should run. Frequency is an // interval in seconds, defaulting to 900 (15 minutes). Its value must be // divisible by 60 and between 60 and 86400 (between 1 minute and 1 day). Frequency int `json:"frequency,omitempty"` // Recipients are notified when the trigger fires. Recipients []TriggerRecipient `json:"recipients,omitempty"` }
Trigger represents a Honeycomb trigger.
API docs: https://docs.honeycomb.io/api/triggers/#fields-on-a-trigger
type TriggerRecipient ¶ added in v0.0.5
type TriggerRecipient struct { // ID of the recipient. ID string `json:"id,omitempty"` // Type of the recipient. Type TriggerRecipientType `json:"type"` // Target of the trigger, this has another meaning depending on type: // - email: an email address // - marker: name of the marker // - PagerDuty: N/A // - Slack: name of a channel // - Webhook: name of the webhook Target string `json:"target,omitempty"` }
TriggerRecipient represents a recipient that will receive a notification when the trigger fires.
API docs: https://docs.honeycomb.io/api/triggers/#specifying-recipients
Notes ¶
Recipients of type Slack should be specified by their ID. It is not possible to create a new recipient of type Slack using the API. Instead use the ID of a recipient of type Slack that was manually added to another trigger.
Recipients of type webhook can be added by their name. If a webhook with this name does not exist yet (or if the name contains a typo), the Honeycomb API will not complain about this but the webhook will not be valid.
type TriggerRecipientType ¶ added in v0.0.8
type TriggerRecipientType string
TriggerRecipientType holds all the possible trigger recipient types.
const ( TriggerRecipientTypeEmail TriggerRecipientType = "email" TriggerRecipientTypeMarker TriggerRecipientType = "marker" TriggerRecipientTypePagerDuty TriggerRecipientType = "pagerduty" TriggerRecipientTypeSlack TriggerRecipientType = "slack" TriggerRecipientTypeWebhook TriggerRecipientType = "webhook" )
Declaration of trigger recipient types
func TriggerRecipientTypes ¶ added in v0.1.0
func TriggerRecipientTypes() []TriggerRecipientType
TriggerRecipientTypes returns an exhaustive list of trigger recipient types.
type TriggerThreshold ¶ added in v0.0.5
type TriggerThreshold struct { Op TriggerThresholdOp `json:"op"` Value float64 `json:"value"` }
TriggerThreshold represents the threshold of a trigger.
type TriggerThresholdOp ¶ added in v0.0.5
type TriggerThresholdOp string
TriggerThresholdOp the operator of the trigger threshold.
const ( TriggerThresholdOpGreaterThan TriggerThresholdOp = ">" TriggerThresholdOpGreaterThanOrEqual TriggerThresholdOp = ">=" TriggerThresholdOpLessThan TriggerThresholdOp = "<" TriggerThresholdOpLessThanOrEqual TriggerThresholdOp = "<=" )
Declaration of trigger threshold ops.
func TriggerThresholdOps ¶ added in v0.1.0
func TriggerThresholdOps() []TriggerThresholdOp
TriggerThresholdOps returns an exhaustive list of trigger threshold ops.
type Triggers ¶ added in v0.0.5
type Triggers interface { // List all triggers present in this dataset. List(ctx context.Context, dataset string) ([]Trigger, error) // Get a trigger by its ID. Returns ErrNotFound if there is no trigger with // the given ID in this dataset. Get(ctx context.Context, dataset string, id string) (*Trigger, error) // Create a new trigger in this dataset. When creating a new trigger ID // may not be set. Create(ctx context.Context, dataset string, t *Trigger) (*Trigger, error) // Update an existing trigger. Missing (optional) fields will set to their // respective defaults and not the currently existing values. Except for // the disabled flag, which will retain its existing value when omitted. Update(ctx context.Context, dataset string, t *Trigger) (*Trigger, error) // Delete a trigger from the dataset. Delete(ctx context.Context, dataset string, id string) error }
Triggers describes all the trigger-related methods that the Honeycomb API supports.
API docs: https://docs.honeycomb.io/api/triggers/