mackerel-client-go: github.com/mackerelio/mackerel-client-go Index | Files

package mackerel

import "github.com/mackerelio/mackerel-client-go"

Index

Package Files

alerts.go dashboards.go error.go graph_annotation.go graph_defs.go host_metadata.go hosts.go mackerel.go metrics.go monitors.go org.go services.go

type APIError Uses

type APIError struct {
    StatusCode int
    Message    string
}

APIError represents the error type from Mackerel API.

func (*APIError) Error Uses

func (err *APIError) Error() string

type Alert Uses

type Alert struct {
    ID        string  `json:"id,omitempty"`
    Status    string  `json:"status,omitempty"`
    MonitorID string  `json:"monitorId,omitempty"`
    Type      string  `json:"type,omitempty"`
    HostID    string  `json:"hostId,omitempty"`
    Value     float64 `json:"value,omitempty"`
    Message   string  `json:"message,omitempty"`
    Reason    string  `json:"reason,omitempty"`
    OpenedAt  int64   `json:"openedAt,omitempty"`
    ClosedAt  int64   `json:"closedAt,omitempty"`
}

Alert information

type BlockDevice Uses

type BlockDevice map[string]map[string]interface{}

BlockDevice blockdevice

type CPU Uses

type CPU []map[string]interface{}

CPU cpu

type Client Uses

type Client struct {
    BaseURL           *url.URL
    APIKey            string
    Verbose           bool
    UserAgent         string
    AdditionalHeaders http.Header
    HTTPClient        *http.Client
}

Client api client for mackerel

func NewClient Uses

func NewClient(apikey string) *Client

NewClient returns new mackerel.Client

func NewClientWithOptions Uses

func NewClientWithOptions(apikey string, rawurl string, verbose bool) (*Client, error)

NewClientWithOptions returns new mackerel.Client

func (*Client) CloseAlert Uses

func (c *Client) CloseAlert(alertID string, reason string) (*Alert, error)

CloseAlert close alert

func (*Client) CreateDashboard Uses

func (c *Client) CreateDashboard(param *Dashboard) (*Dashboard, error)

CreateDashboard creating dashboard

func (*Client) CreateGraphAnnotation Uses

func (c *Client) CreateGraphAnnotation(annotation *GraphAnnotation) (*GraphAnnotation, error)

CreateGraphAnnotation creates graph annotation.

func (*Client) CreateGraphDefs Uses

func (c *Client) CreateGraphDefs(payloads []*GraphDefsParam) error

CreateGraphDefs create graph defs

func (*Client) CreateHost Uses

func (c *Client) CreateHost(param *CreateHostParam) (string, error)

CreateHost creating host

func (*Client) CreateMonitor Uses

func (c *Client) CreateMonitor(param Monitor) (Monitor, error)

CreateMonitor creating monitor

func (*Client) CreateService Uses

func (c *Client) CreateService(param *CreateServiceParam) (*Service, error)

CreateService creates service

func (*Client) DeleteDashboard Uses

func (c *Client) DeleteDashboard(dashboardID string) (*Dashboard, error)

DeleteDashboard delete dashboard

func (*Client) DeleteGraphAnnotation Uses

func (c *Client) DeleteGraphAnnotation(annotationID string) (*GraphAnnotation, error)

DeleteGraphAnnotation deletes graph annotation.

func (*Client) DeleteHostMetaData Uses

func (c *Client) DeleteHostMetaData(hostID, namespace string) error

DeleteHostMetaData delete host metadata.

func (*Client) DeleteMonitor Uses

func (c *Client) DeleteMonitor(monitorID string) (Monitor, error)

DeleteMonitor update monitor

func (*Client) DeleteService Uses

func (c *Client) DeleteService(serviceName string) (*Service, error)

DeleteService deletes service

func (*Client) FetchHostMetricValues Uses

func (c *Client) FetchHostMetricValues(hostID string, metricName string, from int64, to int64) ([]MetricValue, error)

FetchHostMetricValues retrieves the metric values for a Host

func (*Client) FetchLatestMetricValues Uses

func (c *Client) FetchLatestMetricValues(hostIDs []string, metricNames []string) (LatestMetricValues, error)

FetchLatestMetricValues fetch latest metrics

func (*Client) FetchServiceMetricValues Uses

func (c *Client) FetchServiceMetricValues(serviceName string, metricName string, from int64, to int64) ([]MetricValue, error)

FetchServiceMetricValues retrieves the metric values for a Service

func (*Client) FindAlerts Uses

func (c *Client) FindAlerts() ([]*Alert, error)

FindAlerts find alerts

func (*Client) FindDashboard Uses

func (c *Client) FindDashboard(dashboardID string) (*Dashboard, error)

FindDashboard find dashboard

func (*Client) FindDashboards Uses

func (c *Client) FindDashboards() ([]*Dashboard, error)

FindDashboards find dashboards

func (*Client) FindGraphAnnotations Uses

func (c *Client) FindGraphAnnotations(service string, from int64, to int64) ([]GraphAnnotation, error)

FindGraphAnnotations fetches graph annotation.

func (*Client) FindHost Uses

func (c *Client) FindHost(id string) (*Host, error)

FindHost find the host

func (*Client) FindHosts Uses

func (c *Client) FindHosts(param *FindHostsParam) ([]*Host, error)

FindHosts find hosts

func (*Client) FindMonitors Uses

func (c *Client) FindMonitors() ([]Monitor, error)

FindMonitors find monitors

func (*Client) FindServices Uses

func (c *Client) FindServices() ([]*Service, error)

FindServices finds services.

func (*Client) GetHostMetaData Uses

func (c *Client) GetHostMetaData(hostID, namespace string) (*HostMetaDataResp, error)

GetHostMetaData find host metadata.

func (*Client) GetHostMetaDataNameSpaces Uses

func (c *Client) GetHostMetaDataNameSpaces(hostID string) ([]string, error)

GetHostMetaDataNameSpaces fetches namespaces of host metadata.

func (*Client) GetOrg Uses

func (c *Client) GetOrg() (*Org, error)

GetOrg get the org

func (*Client) PostHostMetricValues Uses

func (c *Client) PostHostMetricValues(metricValues [](*HostMetricValue)) error

PostHostMetricValues post host metrics

func (*Client) PostHostMetricValuesByHostID Uses

func (c *Client) PostHostMetricValuesByHostID(hostID string, metricValues [](*MetricValue)) error

PostHostMetricValuesByHostID post host metrics

func (*Client) PostJSON Uses

func (c *Client) PostJSON(path string, payload interface{}) (*http.Response, error)

PostJSON shortcut method for posting json

func (*Client) PostServiceMetricValues Uses

func (c *Client) PostServiceMetricValues(serviceName string, metricValues [](*MetricValue)) error

PostServiceMetricValues post service metrics

func (*Client) PutHostMetaData Uses

func (c *Client) PutHostMetaData(hostID, namespace string, metadata HostMetaData) error

PutHostMetaData put host metadata.

func (*Client) PutJSON Uses

func (c *Client) PutJSON(path string, payload interface{}) (*http.Response, error)

PutJSON shortcut method for putting json

func (*Client) Request Uses

func (c *Client) Request(req *http.Request) (resp *http.Response, err error)

Request request to mackerel and receive response

func (*Client) RetireHost Uses

func (c *Client) RetireHost(id string) error

RetireHost retuire the host

func (*Client) UpdateDashboard Uses

func (c *Client) UpdateDashboard(dashboardID string, param *Dashboard) (*Dashboard, error)

UpdateDashboard update dashboard

func (*Client) UpdateGraphAnnotation Uses

func (c *Client) UpdateGraphAnnotation(annotationID string, annotation *GraphAnnotation) (*GraphAnnotation, error)

UpdateGraphAnnotation updates graph annotation.

func (*Client) UpdateHost Uses

func (c *Client) UpdateHost(hostID string, param *UpdateHostParam) (string, error)

UpdateHost updates host

func (*Client) UpdateHostRoleFullnames Uses

func (c *Client) UpdateHostRoleFullnames(hostID string, roleFullnames []string) error

UpdateHostRoleFullnames updates host roles

func (*Client) UpdateHostStatus Uses

func (c *Client) UpdateHostStatus(hostID string, status string) error

UpdateHostStatus updates host status

func (*Client) UpdateMonitor Uses

func (c *Client) UpdateMonitor(monitorID string, param Monitor) (Monitor, error)

UpdateMonitor update monitor

type Cloud Uses

type Cloud struct {
    Provider string      `json:"provider,omitempty"`
    MetaData interface{} `json:"metadata,omitempty"`
}

Cloud cloud

type CreateHostParam Uses

type CreateHostParam struct {
    Name             string      `json:"name,omitempty"`
    DisplayName      string      `json:"displayName,omitempty"`
    Meta             HostMeta    `json:"meta,omitempty"`
    Interfaces       []Interface `json:"interfaces,omitempty"`
    RoleFullnames    []string    `json:"roleFullnames,omitempty"`
    CustomIdentifier string      `json:"customIdentifier,omitempty"`
}

CreateHostParam parameters for CreateHost

type CreateServiceParam Uses

type CreateServiceParam struct {
    Name string `json:"name"`
    Memo string `json:"memo"`
}

CreateServiceParam parameters for CreateService

type Dashboard Uses

type Dashboard struct {
    ID           string `json:"id,omitempty"`
    Title        string `json:"title,omitempty"`
    BodyMarkDown string `json:"bodyMarkdown,omitempty"`
    URLPath      string `json:"urlPath,omitempty"`
    CreatedAt    int64  `json:"createdAt,omitempty"`
    UpdatedAt    int64  `json:"updatedAt,omitempty"`
}

Dashboard information

type FileSystem Uses

type FileSystem map[string]interface{}

FileSystem filesystem

type FindHostsParam Uses

type FindHostsParam struct {
    Service          string
    Roles            []string
    Name             string
    Statuses         []string
    CustomIdentifier string
}

FindHostsParam parameters for FindHosts

type GraphAnnotation Uses

type GraphAnnotation struct {
    ID          string   `json:"id,omitempty"`
    Title       string   `json:"title,omitempty"`
    Description string   `json:"description,omitempty"`
    From        int64    `json:"from,omitempty"`
    To          int64    `json:"to,omitempty"`
    Service     string   `json:"service,omitempty"`
    Roles       []string `json:"roles,omitempty"`
}

GraphAnnotation represents parameters to post graph annotation.

type GraphDefsMetric Uses

type GraphDefsMetric struct {
    Name        string `json:"name"`
    DisplayName string `json:"displayName"`
    IsStacked   bool   `json:"isStacked"`
}

GraphDefsMetric graph metric

type GraphDefsParam Uses

type GraphDefsParam struct {
    Name        string             `json:"name"`
    DisplayName string             `json:"displayName"`
    Unit        string             `json:"unit"`
    Metrics     []*GraphDefsMetric `json:"metrics"`
}

GraphDefsParam parameters for posting graph definitions

type HeaderField Uses

type HeaderField struct {
    Name  string `json:"name"`
    Value string `json:"value"`
}

HeaderField represents key-value pairs in an HTTP header for external http monitoring.

type Host Uses

type Host struct {
    ID               string      `json:"id,omitempty"`
    Name             string      `json:"name,omitempty"`
    DisplayName      string      `json:"displayName,omitempty"`
    CustomIdentifier string      `json:"customIdentifier,omitempty"`
    Type             string      `json:"type,omitempty"`
    Status           string      `json:"status,omitempty"`
    Memo             string      `json:"memo,omitempty"`
    Roles            Roles       `json:"roles,omitempty"`
    RoleFullnames    []string    `json:"roleFullnames,omitempty"`
    IsRetired        bool        `json:"isRetired,omitempty"`
    CreatedAt        int32       `json:"createdAt,omitempty"`
    Meta             HostMeta    `json:"meta,omitempty"`
    Interfaces       []Interface `json:"interfaces,omitempty"`
}

Host host information

func (*Host) DateFromCreatedAt Uses

func (h *Host) DateFromCreatedAt() time.Time

DateFromCreatedAt returns time.Time

func (*Host) GetRoleFullnames Uses

func (h *Host) GetRoleFullnames() []string

GetRoleFullnames getrolefullnames

func (*Host) IPAddresses Uses

func (h *Host) IPAddresses() map[string]string

IPAddresses returns ipaddresses

type HostMeta Uses

type HostMeta struct {
    AgentRevision string      `json:"agent-revision,omitempty"`
    AgentVersion  string      `json:"agent-version,omitempty"`
    BlockDevice   BlockDevice `json:"block_device,omitempty"`
    CPU           CPU         `json:"cpu,omitempty"`
    Filesystem    FileSystem  `json:"filesystem,omitempty"`
    Kernel        Kernel      `json:"kernel,omitempty"`
    Memory        Memory      `json:"memory,omitempty"`
    Cloud         Cloud       `json:"cloud,omitempty"`
}

HostMeta host meta informations

type HostMetaData Uses

type HostMetaData interface{}

HostMetaData represents host metadata body.

type HostMetaDataResp Uses

type HostMetaDataResp struct {
    HostMetaData HostMetaData
    LastModified time.Time
}

HostMetaDataResp represents response for host metadata.

type HostMetricValue Uses

type HostMetricValue struct {
    HostID string `json:"hostId,omitempty"`
    *MetricValue
}

HostMetricValue host metric value

type Interface Uses

type Interface struct {
    Name          string   `json:"name,omitempty"`
    IPAddress     string   `json:"ipAddress,omitempty"`
    IPv4Addresses []string `json:"ipv4Addresses,omitempty"`
    IPv6Addresses []string `json:"ipv6Addresses,omitempty"`
    MacAddress    string   `json:"macAddress,omitempty"`
}

Interface network interface

type Kernel Uses

type Kernel map[string]string

Kernel kernel

type LatestMetricValues Uses

type LatestMetricValues map[string]map[string]*MetricValue

LatestMetricValues latest metric value

type Memory Uses

type Memory map[string]string

Memory memory

type MetricValue Uses

type MetricValue struct {
    Name  string      `json:"name,omitempty"`
    Time  int64       `json:"time,omitempty"`
    Value interface{} `json:"value,omitempty"`
}

MetricValue metric value

type Monitor Uses

type Monitor interface {
    MonitorType() string
    MonitorID() string
    MonitorName() string
    // contains filtered or unexported methods
}

Monitor represents interface to which each monitor type must confirm to.

type MonitorConnectivity Uses

type MonitorConnectivity struct {
    ID                   string `json:"id,omitempty"`
    Name                 string `json:"name,omitempty"`
    Memo                 string `json:"memo,omitempty"`
    Type                 string `json:"type,omitempty"`
    IsMute               bool   `json:"isMute,omitempty"`
    NotificationInterval uint64 `json:"notificationInterval,omitempty"`

    Scopes        []string `json:"scopes,omitempty"`
    ExcludeScopes []string `json:"excludeScopes,omitempty"`
}

MonitorConnectivity represents connectivity monitor.

func (*MonitorConnectivity) MonitorID Uses

func (m *MonitorConnectivity) MonitorID() string

MonitorID returns monitor id.

func (*MonitorConnectivity) MonitorName Uses

func (m *MonitorConnectivity) MonitorName() string

MonitorName returns monitor name.

func (*MonitorConnectivity) MonitorType Uses

func (m *MonitorConnectivity) MonitorType() string

MonitorType returns monitor type.

type MonitorExpression Uses

type MonitorExpression struct {
    ID                   string `json:"id,omitempty"`
    Name                 string `json:"name,omitempty"`
    Memo                 string `json:"memo,omitempty"`
    Type                 string `json:"type,omitempty"`
    IsMute               bool   `json:"isMute,omitempty"`
    NotificationInterval uint64 `json:"notificationInterval,omitempty"`

    Expression string   `json:"expression,omitempty"`
    Operator   string   `json:"operator,omitempty"`
    Warning    *float64 `json:"warning"`
    Critical   *float64 `json:"critical"`
}

MonitorExpression represents expression monitor.

func (*MonitorExpression) MonitorID Uses

func (m *MonitorExpression) MonitorID() string

MonitorID returns monitor id.

func (*MonitorExpression) MonitorName Uses

func (m *MonitorExpression) MonitorName() string

MonitorName returns monitor name.

func (*MonitorExpression) MonitorType Uses

func (m *MonitorExpression) MonitorType() string

MonitorType returns monitor type.

type MonitorExternalHTTP Uses

type MonitorExternalHTTP struct {
    ID                   string `json:"id,omitempty"`
    Name                 string `json:"name,omitempty"`
    Memo                 string `json:"memo,omitempty"`
    Type                 string `json:"type,omitempty"`
    IsMute               bool   `json:"isMute,omitempty"`
    NotificationInterval uint64 `json:"notificationInterval,omitempty"`

    Method                          string   `json:"method,omitempty"`
    URL                             string   `json:"url,omitempty"`
    MaxCheckAttempts                uint64   `json:"maxCheckAttempts,omitempty"`
    Service                         string   `json:"service,omitempty"`
    ResponseTimeCritical            *float64 `json:"responseTimeCritical,omitempty"`
    ResponseTimeWarning             *float64 `json:"responseTimeWarning,omitempty"`
    ResponseTimeDuration            *uint64  `json:"responseTimeDuration,omitempty"`
    RequestBody                     string   `json:"requestBody,omitempty"`
    ContainsString                  string   `json:"containsString,omitempty"`
    CertificationExpirationCritical *uint64  `json:"certificationExpirationCritical,omitempty"`
    CertificationExpirationWarning  *uint64  `json:"certificationExpirationWarning,omitempty"`
    SkipCertificateVerification     bool     `json:"skipCertificateVerification,omitempty"`
    // Empty list of headers and nil are different. You have to specify empty
    // list as headers explicitly if you want to remove all headers instead of
    // using nil.
    Headers []HeaderField `json:"headers"`
}

MonitorExternalHTTP represents external HTTP monitor.

func (*MonitorExternalHTTP) MonitorID Uses

func (m *MonitorExternalHTTP) MonitorID() string

MonitorID returns monitor id.

func (*MonitorExternalHTTP) MonitorName Uses

func (m *MonitorExternalHTTP) MonitorName() string

MonitorName returns monitor name.

func (*MonitorExternalHTTP) MonitorType Uses

func (m *MonitorExternalHTTP) MonitorType() string

MonitorType returns monitor type.

type MonitorHostMetric Uses

type MonitorHostMetric struct {
    ID                   string `json:"id,omitempty"`
    Name                 string `json:"name,omitempty"`
    Memo                 string `json:"memo,omitempty"`
    Type                 string `json:"type,omitempty"`
    IsMute               bool   `json:"isMute,omitempty"`
    NotificationInterval uint64 `json:"notificationInterval,omitempty"`

    Metric           string   `json:"metric,omitempty"`
    Operator         string   `json:"operator,omitempty"`
    Warning          *float64 `json:"warning"`
    Critical         *float64 `json:"critical"`
    Duration         uint64   `json:"duration,omitempty"`
    MaxCheckAttempts uint64   `json:"maxCheckAttempts,omitempty"`

    Scopes        []string `json:"scopes,omitempty"`
    ExcludeScopes []string `json:"excludeScopes,omitempty"`
}

MonitorHostMetric represents host metric monitor.

func (*MonitorHostMetric) MonitorID Uses

func (m *MonitorHostMetric) MonitorID() string

MonitorID returns monitor id.

func (*MonitorHostMetric) MonitorName Uses

func (m *MonitorHostMetric) MonitorName() string

MonitorName returns monitor name.

func (*MonitorHostMetric) MonitorType Uses

func (m *MonitorHostMetric) MonitorType() string

MonitorType returns monitor type.

type MonitorServiceMetric Uses

type MonitorServiceMetric struct {
    ID                   string `json:"id,omitempty"`
    Name                 string `json:"name,omitempty"`
    Memo                 string `json:"memo,omitempty"`
    Type                 string `json:"type,omitempty"`
    IsMute               bool   `json:"isMute,omitempty"`
    NotificationInterval uint64 `json:"notificationInterval,omitempty"`

    Service          string   `json:"service,omitempty"`
    Metric           string   `json:"metric,omitempty"`
    Operator         string   `json:"operator,omitempty"`
    Warning          *float64 `json:"warning"`
    Critical         *float64 `json:"critical"`
    Duration         uint64   `json:"duration,omitempty"`
    MaxCheckAttempts uint64   `json:"maxCheckAttempts,omitempty"`
}

MonitorServiceMetric represents service metric monitor.

func (*MonitorServiceMetric) MonitorID Uses

func (m *MonitorServiceMetric) MonitorID() string

MonitorID returns monitor id.

func (*MonitorServiceMetric) MonitorName Uses

func (m *MonitorServiceMetric) MonitorName() string

MonitorName returns monitor name.

func (*MonitorServiceMetric) MonitorType Uses

func (m *MonitorServiceMetric) MonitorType() string

MonitorType returns monitor type.

type Org Uses

type Org struct {
    Name string `json:"name"`
}

Org information

type Roles Uses

type Roles map[string][]string

Roles host role maps

type Service Uses

type Service struct {
    Name  string   `json:"name,omitempty"`
    Memo  string   `json:"memo,omitempty"`
    Roles []string `json:"roles,omitempty"`
}

Service represents Mackerel "service".

type UpdateHostParam Uses

type UpdateHostParam CreateHostParam

UpdateHostParam parameters for UpdateHost

Package mackerel imports 13 packages (graph) and is imported by 8 packages. Updated 2018-06-28. Refresh now. Tools for package owners.