예제 #1
0
// Converts Timeseries to metric structure used by the Hawkular
func (h *hawkularSink) pointToLabeledMetricHeader(ms *core.MetricSet, metric core.LabeledMetric, timestamp time.Time) (*metrics.MetricHeader, error) {

	name := h.idName(ms, metric.Name)
	if resourceID, found := metric.Labels[core.LabelResourceID.Key]; found {
		name = h.idName(ms, metric.Name+separator+resourceID)
	}

	var value float64
	if metric.ValueType == core.ValueInt64 {
		value = float64(metric.IntValue)
	} else {
		value = float64(metric.FloatValue)
	}

	m := metrics.Datapoint{
		Value:     value,
		Timestamp: metrics.UnixMilli(timestamp),
	}

	mh := &metrics.MetricHeader{
		Id:   name,
		Data: []metrics.Datapoint{m},
		Type: heapsterTypeToHawkularType(metric.MetricType),
	}

	return mh, nil
}
예제 #2
0
// Converts Timeseries to metric structure used by the Hawkular
func (self *hawkularSink) pointToMetricHeader(t *sink_api.Timeseries) (*metrics.MetricHeader, error) {

	p := t.Point
	name := self.idName(p)

	value, err := metrics.ConvertToFloat64(p.Value)
	if err != nil {
		return nil, err
	}

	m := metrics.Datapoint{
		Value:     value,
		Timestamp: metrics.UnixMilli(p.End),
	}

	mh := &metrics.MetricHeader{
		Id:   name,
		Data: []metrics.Datapoint{m},
		Type: heapsterTypeToHawkularType(t.MetricDescriptor.Type),
	}

	return mh, nil
}
예제 #3
0
// Converts Timeseries to metric structure used by the Hawkular
func (self *hawkularSink) pointToMetricHeader(t *sink_api.Timeseries) (*metrics.MetricHeader, error) {

	p := t.Point
	name := self.idName(p)

	value, err := metrics.ConvertToFloat64(p.Value)
	if err != nil {
		return nil, err
	}

	m := metrics.Datapoint{
		Value:     value,
		Timestamp: metrics.UnixMilli(p.End),
	}

	// At the moment all the values are converted to gauges.
	mh := &metrics.MetricHeader{
		Id:   name,
		Data: []metrics.Datapoint{m},
		Type: metrics.Gauge,
	}
	return mh, nil
}