Exemplo n.º 1
0
func (a *Api) exportMetricsSchema(request *restful.Request, response *restful.Response) {
	result := TimeseriesSchema{}
	for _, label := range sinksApi.CommonLabels() {
		result.CommonLabels = append(result.CommonLabels, LabelDescriptor{
			Key:         label.Key,
			Description: label.Description,
		})
	}
	for _, label := range sinksApi.PodLabels() {
		result.PodLabels = append(result.PodLabels, LabelDescriptor{
			Key:         label.Key,
			Description: label.Description,
		})
	}

	for _, metric := range sinksApi.SupportedStatMetrics() {
		md := MetricDescriptor{
			Name:        metric.Name,
			Description: metric.Description,
			Type:        metric.Type.String(),
			ValueType:   metric.ValueType.String(),
			Units:       metric.Units.String(),
		}
		for _, label := range metric.Labels {
			md.Labels = append(md.Labels, LabelDescriptor{
				Key:         label.Key,
				Description: label.Description,
			})
		}
		result.Metrics = append(result.Metrics, md)
	}
	response.WriteEntity(result)
}
Exemplo n.º 2
0
func supportedMetricsDescriptors() []sink_api.MetricDescriptor {
	// Get supported metrics.
	supportedMetrics := sink_api.SupportedStatMetrics()
	for i := range supportedMetrics {
		supportedMetrics[i].Labels = sink_api.SupportedLabels()
	}

	// Create the metrics.
	descriptors := make([]sink_api.MetricDescriptor, 0, len(supportedMetrics))
	for _, supported := range supportedMetrics {
		descriptors = append(descriptors, supported.MetricDescriptor)
	}
	return descriptors
}
Exemplo n.º 3
0
func (esm *externalSinkManager) DebugInfo() string {
	b := &bytes.Buffer{}
	fmt.Fprintln(b, "External Sinks")
	// Add metrics being exported.
	fmt.Fprintln(b, "\tExported metrics:")
	for _, supported := range sink_api.SupportedStatMetrics() {
		fmt.Fprintf(b, "\t\t%s: %s\n", supported.Name, supported.Description)
	}

	// Add labels being used.
	fmt.Fprintln(b, "\tExported labels:")
	for _, label := range sink_api.SupportedLabels() {
		fmt.Fprintf(b, "\t\t%s: %s\n", label.Key, label.Description)
	}
	fmt.Fprintln(b, "\tExternal Sinks:")
	esm.RLock()
	defer esm.RUnlock()
	for _, externalSink := range esm.externalSinks {
		fmt.Fprintf(b, "\t\t%s\n", externalSink.DebugInfo())
	}

	return b.String()
}