Documentation ¶
Overview ¶
Copyright 2018 Google Inc.
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.
Copyright 2018 Google Inc.
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.
Copyright 2018 Google Inc. 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.
Copyright 2017 Google Inc. 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.
Index ¶
Constants ¶
const ( ProjectIdLabel = "_stackdriver_project_id" LocationLabel = "_kubernetes_location" ClusterNameLabel = "_kubernetes_cluster_name" )
const (
MonitoringWriteScope = "https://www.googleapis.com/auth/monitoring.write"
)
Variables ¶
var DefaultResourceMappings = []ResourceMap{ { Type: "gke_container", LabelMap: map[string]string{ ProjectIdLabel: "project_id", LocationLabel: "zone", ClusterNameLabel: "cluster_name", "_kubernetes_namespace": "namespace_id", "_kubernetes_pod_name": "pod_id", "_kubernetes_pod_node_name": "instance_id", "_kubernetes_pod_container_name": "container_name", }, }, }
TODO(jkohen): ensure these are sorted from more specific to less specific.
var ( DefaultStackdriverConfig = StackdriverConfig{ K8sResourceTypes: false, MetricPrefix: "external.googleapis.com/prometheus", } )
var K8sResourceMappings = []ResourceMap{ { Type: "k8s_container", LabelMap: map[string]string{ ProjectIdLabel: "project_id", LocationLabel: "location", ClusterNameLabel: "cluster_name", "__meta_kubernetes_namespace": "namespace_name", "__meta_kubernetes_pod_name": "pod_name", "__meta_kubernetes_pod_container_name": "container_name", }, }, { Type: "k8s_pod", LabelMap: map[string]string{ ProjectIdLabel: "project_id", LocationLabel: "location", ClusterNameLabel: "cluster_name", "__meta_kubernetes_namespace": "namespace_name", "__meta_kubernetes_pod_name": "pod_name", }, }, { Type: "k8s_node", LabelMap: map[string]string{ ProjectIdLabel: "project_id", LocationLabel: "location", ClusterNameLabel: "cluster_name", "__meta_kubernetes_node_name": "node_name", }, }, { Type: "k8s_cluster", LabelMap: map[string]string{ ProjectIdLabel: "project_id", LocationLabel: "location", ClusterNameLabel: "cluster_name", }, }, }
TODO(jkohen): ensure these are sorted from more specific to less specific.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client allows reading and writing from/to a remote gRPC endpoint. The implementation may hit a single backend, so the application should create a number of these clients.
func NewClient ¶
func NewClient(index int, conf *ClientConfig) *Client
NewClient creates a new Client.
func (*Client) Store ¶
func (c *Client) Store(req *monitoring.CreateTimeSeriesRequest) error
Store sends a batch of samples to the HTTP endpoint.
type ClientConfig ¶
type ClientConfig struct { Logger log.Logger ProjectId string // The Stackdriver project id in "projects/name-or-number" format. ClusterName string Location string URL *config_util.URL Timeout model.Duration }
ClientConfig configures a Client.
type QueueManager ¶
type QueueManager struct {
// contains filtered or unexported fields
}
QueueManager manages a queue of samples to be sent to the Storage indicated by the provided StorageClient.
func NewQueueManager ¶
func NewQueueManager(logger log.Logger, cfg config.QueueConfig, externalLabelSet model.LabelSet, relabelConfigs []*config.RelabelConfig, clientFactory StorageClientFactory, sdCfg *StackdriverConfig) *QueueManager
NewQueueManager builds a new QueueManager.
func (*QueueManager) Append ¶
func (t *QueueManager) Append(metricFamily *retrieval.MetricFamily) error
Append queues a sample to be sent to the remote storage. It drops the sample on the floor if the queue is full. Always returns nil.
func (*QueueManager) Start ¶
func (t *QueueManager) Start()
Start the queue manager sending samples to the remote storage. Does not block.
func (*QueueManager) Stop ¶
func (t *QueueManager) Stop()
Stop stops sending samples to the remote storage and waits for pending sends to complete.
type ResourceMap ¶
type StackdriverConfig ¶
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
func NewStorage ¶
func NewStorage(logger log.Logger, cfg *StackdriverConfig) *Storage
func (*Storage) Add ¶
func (s *Storage) Add(metricFamily *retrieval.MetricFamily) error
Add implements the retrieval.Appender interface.
func (*Storage) ApplyConfig ¶
ApplyConfig updates the state as the new config requires.
type StorageClient ¶
type StorageClient interface { // Store stores the given metric families in the remote storage. Store(*monitoring.CreateTimeSeriesRequest) error // Name identifies the remote storage implementation. Name() string // Release the resources allocated by the client. Close() error }
StorageClient defines an interface for sending a batch of samples to an external timeseries database.
type StorageClientFactory ¶
type StorageClientFactory interface { New() StorageClient Name() string }
type Translator ¶
type Translator struct {
// contains filtered or unexported fields
}
Translator allows converting Prometheus samples to Stackdriver TimeSeries.
func NewTranslator ¶
func NewTranslator(logger log.Logger, metricsPrefix string, resourceMappings []ResourceMap) *Translator
NewTranslator creates a new Translator.
func (*Translator) ToCreateTimeSeriesRequest ¶
func (t *Translator) ToCreateTimeSeriesRequest( metrics []*retrieval.MetricFamily) *monitoring_pb.CreateTimeSeriesRequest
ToCreateTimeSeriesRequest translates metrics in Prometheus format to Stackdriver format.