Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions metrics/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
Copyright 2018 The Knative Authors
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.
*/

// Package metrics provides Knative utilities for exporting metrics to Stackdriver
// backend or Prometheus backend based on config-observability settings.
package metrics
62 changes: 62 additions & 0 deletions metrics/metricskey/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
Copyright 2018 The Knative Authors
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.
*/

package metricskey

const (
// ResourceTypeKnativeRevision is the Stackdriver resource type for Knative revision
ResourceTypeKnativeRevision = "knative_revision"

// LabelProject is the label for project (e.g. GCP GAIA ID, AWS project name)
LabelProject = "project"

// LabelLocation is the label for location (e.g. GCE zone, AWS region) where the service is deployed
LabelLocation = "location"

// LabelClusterName is the label for immutable name of the cluster
LabelClusterName = "cluster_name"

// LabelNamespaceName is the label for immutable name of the namespace that the service is deployed
LabelNamespaceName = "namespace_name"

// LabelServiceName is the label for the deployed service name
LabelServiceName = "service_name"

// LabelConfigurationName is the label for the configuration which created the monitored revision
LabelConfigurationName = "configuration_name"

// LabelRevisionName is the label for the monitored revision
LabelRevisionName = "revision_name"

// ValueUnknown is the default value if the field is unknown, e.g. project will be unknown if Knative
// is not running on GKE.
ValueUnknown = "unknown"
)

var (
// KnativeRevisionLabels stores the set of resource labels for resource type knative_revision
KnativeRevisionLabels = map[string]struct{}{
LabelProject: struct{}{},
LabelLocation: struct{}{},
LabelClusterName: struct{}{},
LabelNamespaceName: struct{}{},
LabelServiceName: struct{}{},
LabelConfigurationName: struct{}{},
LabelRevisionName: struct{}{},
}

// ResourceTypeToLabelsMap maps resource type to the set of resource labels
ResourceTypeToLabelsMap = map[string]map[string]struct{}{
ResourceTypeKnativeRevision: KnativeRevisionLabels,
}
)