# README
mackerel-client-go
mackerel-client-go is a Go client library for mackerel.io API.
Usage
import "github.com/mackerelio/mackerel-client-go"
client := mackerel.NewClient("<Put your API key>")
hosts, err := client.FindHosts(&mackerel.FindHostsParam{
Service: "My-Service",
Roles: []string{"proxy"},
Statuses: []string{mackerel.HostStatusWorking},
})
err := client.PostServiceMetricValues("My-Service", []*mackerel.MetricValue{
&mackerel.MetricValue{
Name: "proxy.access_log.latency",
Time: 123456789,
Value: 500,
},
})
CAUTION
Now, mackerel-client-go is an ALPHA version. In the future release, it may change it's interface.
CONTRIBUTION
- Fork (https://github.com/mackerelio/mackerel-client-go/fork)
- Create a feature branch
- Commit your changes
- Rebase your local changes against the master branch
- Run test suite with the
go test ./...
command and confirm that it passes - Run
gofmt -s
- Create new Pull Request
License
Copyright 2014 Hatena Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
# Functions
NewCheckSourceHost returns new CheckSource which check type is "host".
NewClient returns new mackerel.Client.
NewClientWithOptions returns new mackerel.Client.
# Constants
CheckStatuses.
CheckStatuses.
CheckStatuses.
CheckStatuses.
DowntimeRecurrenceType ...
DowntimeRecurrenceType ...
DowntimeRecurrenceType ...
DowntimeRecurrenceType ...
DowntimeRecurrenceType ...
HostStatusMaintenance represents "maintenance" status.
HostStatusPoweroff represents "poeroff" status.
HostStatusStandby represents "standby" status.
HostStatusWorking represents "working" status.
NotificationLevels.
NotificationLevels.
# Structs
Alert information.
AlertGroupSetting represents a Mackerel alert group setting.
AlertsResp includes alert and next id.
APIError represents the error type from Mackerel API.
AWSIntegration AWS integration information.
AWSIntegrationService integration settings for each AWS service.
Channel represents a Mackerel notification channel.
CheckConfig is check plugin name and memo.
CheckReport represents a report of check monitoring.
CheckReports represents check reports for API.
Client api client for mackerel.
Cloud cloud.
CreateAWSIntegrationParam parameters for CreateAWSIntegration.
CreateHostParam parameters for CreateHost.
CreateServiceParam parameters for CreateService.
Dashboard information.
Downtime information.
DowntimeRecurrence ...
FindHostByCustomIdentifierParam parameters for FindHostByCustomIdentifier.
FindHostsParam parameters for FindHosts.
FormatRule information.
Graph information.
GraphAnnotation represents parameters to post a graph annotation.
GraphDefsMetric graph metric.
GraphDefsParam parameters for posting graph definitions.
HeaderField represents key-value pairs in an HTTP header for external http monitoring.
Host host information.
HostMeta host meta informations.
HostMetaDataResp represents response for host metadata.
HostMetricValue host metric value.
Interface network interface.
Invitation information.
Layout information.
Mentions represents the structure used for slack channel mentions.
Metric information.
MetricValue metric value.
MonitorAnomalyDetection represents anomaly detection monitor.
MonitorConnectivity represents connectivity monitor.
MonitoredStatus monitored status.
MonitoredStatusDetail monitored status detail.
MonitorExpression represents expression monitor.
MonitorExternalHTTP represents external HTTP monitor.
MonitorHostMetric represents host metric monitor.
MonitorQuery represents query monitor.
MonitorServiceMetric represents service metric monitor.
NotificationGroup represents a Mackerel notification group.
NotificationGroupMonitor represents a notification target monitor rule.
NotificationGroupService represents a notification target service.
Org information.
Range information.
ReferenceLine information.
Role represents Mackerel "role".
RoleMetaDataResp represents response for role metadata.
Service represents Mackerel "service".
ServiceMetaDataResp represents response for service metadata.
UpdateAlertParam is for UpdateAlert.
UpdateAlertResponse is for UpdateAlert.
User information.
Widget information.
# Interfaces
CheckSource represents interface to which each check source type must confirm to.
HostMetaData represents host metadata body.
{
"monitors": [
{
"id": "2cSZzK3XfmG",
"type": "connectivity",
"isMute": false,
"scopes": [],
"excludeScopes": [],
"alertStatusOnGone": "WARNING"
},
{
"id" : "2cSZzK3XfmG",
"type": "host",
"isMute": false,
"name": "disk.aa-00.writes.delta",
"duration": 3,
"metric": "disk.aa-00.writes.delta",
"operator": ">",
"warning": 20000.0,
"critical": 400000.0,
"scopes": [
"SomeService"
],
"excludeScopes": [
"SomeService: db-slave-backup"
],
"maxCheckAttempts": 1,
"notificationInterval": 60
},
{
"id" : "2cSZzK3XfmG",
"type": "service",
"isMute": false,
"name": "SomeService - custom.access_num.4xx_count",
"service": "SomeService",
"duration": 1,
"metric": "custom.access_num.4xx_count",
"operator": ">",
"warning": 50.0,
"critical": 100.0,
"maxCheckAttempts": 1,
"missingDurationWarning": 360,
"missingDurationCritical": 720
},
{
"id" : "2cSZzK3XfmG",
"type": "external",
"isMute": false,
"name": "example.com",
"method": "GET",
"url": "http://www.example.com",
"service": "SomeService",
"maxCheckAttempts": 1,
"responseTimeCritical": 10000,
"responseTimeWarning": 5000,
"responseTimeDuration": 5,
"certificationExpirationCritical": 15,
"certificationExpirationWarning": 30,
"requestBody": "Request Body",
"containsString": "Example",
"skipCertificateVerification": true,
"followRedirect": true,
"headers": [
{ "name": "Cache-Control", "value": "no-cache"}
]
},
{
"id": "3CSsK3HKiHb",
"type": "anomalyDetection",
"isMute": false,
"name": "My first anomaly detection",
"trainingPeriodFrom": 1561429260,
"scopes": [
"MyService: MyRole"
],
"maxCheckAttempts": 3,
"warningSensitivity": "insensitive"
},
{
"id": "57We5nNtpZA",
"type": "query",
"isMute": false,
"name": "LabeldMetric - custom.access_counter",
"query": "custom.access_counter",
"operator": ">",
"warning": 30.0,
"critical": 300.0,
"legend":""
}
]
}
*/ Monitor represents interface to which each monitor type must confirm to.
PrioritizedLogger is the interface that groups prioritized logging methods.
RoleMetaData represents role metadata body.
ServiceMetaData represents service metadata body.
# Type aliases
BlockDevice blockdevice.
CheckStatus represents check monitoring status.
CPU cpu.
CreateRoleParam parameters for CreateRole.
DowntimeRecurrenceType ...
DowntimeWeekday ...
FileSystem filesystem.
Kernel kernel.
LatestMetricValues latest metric value.
ListAWSIntegrationExcludableMetrics List of excludeable metric names for AWS integration.
Memory memory.
NotificationLevel represents a level of notification.
Roles host role maps.
UpdateAWSIntegrationParam parameters for UpdateAwsIntegration.
UpdateHostParam parameters for UpdateHost.