id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c22100
gkeLabels[val.Key] = val } for _, val := range core.PodLabels() { gkeLabels[val.Key] = val } return &Api{ runningInKubernetes: runningInKubernetes, metricSink: metricSink, historicalSource: historicalSource, gkeMetrics: gkeMetrics, gkeLabels: gkeLabels, disabled: ...
c22101
Produces(restful.MIME_JSON) ws.Route(ws.GET(""). To(a.exportMetricsSchema). Doc("export the schema for all metrics"). Operation("exportmetricsSchema"). Writes(types.TimeseriesSchema{})) container.Add(ws) if a.metricSink != nil { a.RegisterModel(container) } if a.historicalSource != nil { a.RegisterH...
c22102
metric := range core.AllMetrics { metrics = append(metrics, metric.MetricDescriptor) } sink.Register(metrics) return sink, nil }
c22103
hasAlias = a.Indices[indexName].HasAlias(aliasName) } if !hasAlias { createAlias, err := esSvc.EsClient.AddAlias(indexName, esSvc.IndexAlias(typeName)) if err != nil { return err } ack := false switch i := createAlias.(type) { case *elastic2.AliasResult: ack = i.Acknowledged case *elastic5.Alia...
c22104
creating an InfluxDB sink: %v, will retry on use", err) } return &influxdbSink{ client: client, // can be nil c: c, conChan: make(chan struct{}, c.Concurrency), } }
c22105
obj.(*rbacv1.ClusterRoleBinding) if !ok { return nil, fmt.Errorf("Failed to cast clusterrolebinding: %v", obj) } return rbac, nil }
c22106
err := self.kubeClient.RbacV1().ClusterRoleBindings().Create(rbac) return err }
c22107
obj.(*v1.ServiceAccount) if !ok { return nil, fmt.Errorf("Failed to cast serviceaccount: %v", obj) } return sa, nil }
c22108
err := self.kubeClient.CoreV1().ServiceAccounts(sa.Namespace).Create(sa) return err }
c22109
offset := i + maxBatchSize if offset > len(batch) { offset = len(batch) } if err := c.sendBatch(batch[i:offset]); err != nil { errs = append(errs, err.Error()) } } if len(errs) > 0 { return errors.New(strings.Join(errs, "\n")) } return nil }
c22110
return fmt.Errorf("Invalid metric name %q", name) } return nil }
c22111
we're somewhat more permissive. We allow any // Printable unicode character, except quotation marks, which are used // to delimit things. if strings.ContainsRune(v, '"') || strings.ContainsRune(v, '\'') { return fmt.Errorf("Invalid label value %q", v) } for _, runeVal := range v { if !unicode.IsPrint...
c22112
return fmt.Sprintf("PERCENTILE(%q, 50)", fieldName) case core.AggregationTypePercentile95: return fmt.Sprintf("PERCENTILE(%q, 95)", fieldName) case core.AggregationTypePercentile99: return fmt.Sprintf("PERCENTILE(%q, 99)", fieldName) } // This should have been checked by the API level, so something's seriousl...
c22113
core.LabelPodId.Key, key.PodId, core.LabelContainerName.Key, key.ContainerName) } else { return fmt.Sprintf("%s AND %s = '%s' AND %s = '%s' AND %s = '%s'", typeSel, core.LabelNamespaceName.Key, key.NamespaceName, core.LabelPodName.Key, key.PodName, core.LabelContainerName.Key, key.ContainerName) } } // These...
c22114
parts = append(parts, fmt.Sprintf("%q = '%s'", k, v)) } return strings.Join(parts, " AND ") }
c22115
start.Format(time.RFC3339)) } if !end.IsZero() { pred += fmt.Sprintf(" AND time < '%s'", end.Format(time.RFC3339)) } queries[i] = fmt.Sprintf("SELECT time, %q FROM %q WHERE %s", fieldName, seriesName, pred) } return strings.Join(queries, "; ") }
c22116
{ glog.Errorf("Unable to parse field \"value\" in series %q: %v", rawRow.Name, err) return nil, fmt.Errorf("Unable to parse values in series %q", rawRow.Name) } vals[i] = val } if wasInt["value"] { for i := range vals { vals[i].MetricValue.ValueType = core.ValueInt64 } } else { for i := range v...
c22117
%s FROM %q WHERE %s", strings.Join(aggParts, ", "), seriesName, pred) if bucketSize != 0 { // group by time requires we have at least one time bound if start.IsZero() && end.IsZero() { queries[i] += fmt.Sprintf(" AND time < now()") } // fill(none) makes sure we skip data points will null values (ot...
c22118
err != nil { glog.Errorf("Unable to parse count value in series %q: %v", rawRow.Name, err) return nil, fmt.Errorf("Unable to parse values in series %q", rawRow.Name) } } // The rest of the aggregation values can be either float or int, so attempt to parse both if err := populateAggregations(rawRow.Na...
c22119
:= tryParseMetricValue(string(aggName), rawVal, targetValue, fieldIndex, wasInt); err != nil { return err } aggregations.Aggregations[aggName] = *targetValue } return nil }
c22120
rv = rvN.String() } tryInt := false isInt, triedBefore := wasInt[aggName] tryInt = isInt || !triedBefore if tryInt { if err := json.Unmarshal([]byte(rv), &targetValue.IntValue); err != nil { wasInt[aggName] = false } else { wasInt[aggName] = true } } if err := json.Unmarshal([]byte(rv), &targetV...
c22121
} return sink.stringListQuery(fmt.Sprintf("SHOW MEASUREMENTS WHERE %s", sink.keyToSelector(metricKey)), "Unable to list available metrics") }
c22122
= %s", core.LabelNodename.Key), "Unable to list all nodes") }
c22123
= %s", core.LabelNamespaceName.Key), "Unable to list all namespaces") }
c22124
= '%s'", core.MetricUptime.MetricDescriptor.Name, core.LabelNamespaceName.Key, namespace, core.MetricSetTypePod) return sink.stringListQueryCol(q, core.LabelPodName.Key, fmt.Sprintf("Unable to list pods in namespace %q", namespace)) }
c22125
for the uptime measurement for system containers on our node // (any measurement should work here, though) q := fmt.Sprintf("SHOW SERIES FROM %q WHERE %s = '%s' AND type = '%s'", core.MetricUptime.MetricDescriptor.Name, core.LabelNodename.Key, node, core.MetricSetTypeSystemContainer) return sink.stringListQueryCol(...
c22126
} if colInd == -1 { glog.Errorf("%s: results did not contain the %q column", errStr, core.LabelPodName.Key) return nil, fmt.Errorf(errStr) } res := make([]string, len(resp[0].Series[0].Values)) for i, rv := range resp[0].Series[0].Values { res[i] = rv[colInd].(string) } return res, nil }
c22127
nil, fmt.Errorf(errStr) } res := make([]string, len(resp[0].Series[0].Values)) for i, rv := range resp[0].Series[0].Values { res[i] = rv[0].(string) } return res, nil }
c22128
glog.Errorf("Unable to parse field %q in series %q: %v", aggregation, rawRowName, err) return fmt.Errorf("Unable to parse values in series %q", rawRowName) } } return nil }
c22129
{ for i := range vals { val := vals[i].Aggregations[aggregation] val.ValueType = core.ValueFloat vals[i].Aggregations[aggregation] = val } } } }
c22130
core.MetricGauge: metricKind = "GAUGE" case core.MetricDelta: metricKind = "DELTA" } var valueType string switch metric.MetricDescriptor.ValueType { case core.ValueInt64: valueType = "INT64" case core.ValueFloat: valueType = "DOUBLE" } desc := &gcm.MetricDescriptor{ Name: metri...
c22131
select { case sh.dataBatchChannel <- data: glog.V(2).Infof("Data push completed: %s", sh.sink.Name()) // everything ok case <-time.After(this.exportDataTimeout): glog.Warningf("Failed to push data to sink: %s", sh.sink.Name()) } }(sh, &wg) } // Wait for all pushes to complete or timeout. w...
c22132
:= self.getUrl(host, "/stats/container/") return self.getAllContainers(url, start, end) }
c22133
_, fl := response.ResponseWriter.(http.Flusher) _, hj := response.ResponseWriter.(http.Hijacker) _, rf := response.ResponseWriter.(io.ReaderFrom) var rw http.ResponseWriter if cn && fl && hj && rf { rw = &fancyResponseWriterDelegator{delegate} } else { rw = delegate } response.ResponseWriter = rw ...
c22134
{ return fmt.Sprintf("namespace:%s/pod:%s/container:%s", namespace, podName, containerName) }
c22135
{ metricSet.Labels[core.LabelPodNamespaceUID.Key] = string(namespace.UID) } else { glog.Errorf("Wrong namespace store content") } } else if err != nil { glog.Warningf("Failed to get namespace %s: %v", namespaceName, err) } else if !exists { glog.Warningf("Namespace doesn't exist: %s", namespaceName) }...
c22136
a.processMetricNamesRequest(core.ClusterKey(), response) }
c22137
a.processMetricNamesRequest(core.NodeKey(request.PathParameter("node-name")), response) }
c22138
a.processMetricNamesRequest(core.NamespaceKey(request.PathParameter("namespace-name")), response) }
c22139
return time.Time{}, fmt.Errorf("timestamp argument cannot be parsed: %s", err) } return reqStamp, nil } return defaultValue, nil }
c22140
sink.config.Tags, } // state everywhere events = append(events, event) if len(events) >= sink.config.BatchSize { err := riemannCommon.SendData(sink.client, events) if err != nil { glog.Warningf("Error sending events to Riemann: %v", err) // client will reconnect later sink.client = nil } even...
c22141
labels[k] = v } for k, v := range metric.Labels { labels[k] = v } timestamp := dataBatch.Timestamp.Unix() // creates an event and add it to dataEvent events = appendEvent(events, sink, host, metric.Name, value, labels, timestamp) } } } // Send events to Riemann if events is not...
c22142
core.HistoricalKey{ObjectType: core.MetricSetTypeCluster} a.processMetricNamesRequest(key, response) }
c22143
request.PathParameter("node-name"), } a.processMetricNamesRequest(key, response) }
c22144
NamespaceName: request.PathParameter("namespace-name"), } a.processMetricNamesRequest(key, response) }
c22145
PodName: request.PathParameter("pod-name"), } a.processMetricNamesRequest(key, response) }
c22146
request.PathParameter("pod-name"), ContainerName: request.PathParameter("container-name"), } a.processMetricNamesRequest(key, response) }
c22147
core.MetricSetTypeSystemContainer, NodeName: request.PathParameter("node-name"), ContainerName: request.PathParameter("container-name"), } a.processMetricNamesRequest(key, response) }
c22148
:= a.historicalSource.GetNodes(); err != nil { response.WriteError(http.StatusInternalServerError, err) } else { response.WriteEntity(resp) } }
c22149
:= a.historicalSource.GetNamespaces(); err != nil { response.WriteError(http.StatusInternalServerError, err) } else { response.WriteEntity(resp) } }
c22150
response.WriteError(http.StatusInternalServerError, err) } else { response.WriteEntity(resp) } }
c22151
core.MetricSetTypeSystemContainer, NodeName: request.PathParameter("node-name"), ContainerName: request.PathParameter("container-name"), } a.processMetricRequest(key, request, response) }
c22152
nil { metrics, err = a.historicalSource.GetLabeledMetric(convertedMetricName, labels, keys, start, end) } else { metrics, err = a.historicalSource.GetMetric(convertedMetricName, keys, start, end) } if err != nil { response.WriteError(http.StatusInternalServerError, err) return } result := types.MetricRe...
c22153
core.HistoricalKey{ObjectType: core.MetricSetTypeCluster} a.processAggregationRequest(key, request, response) }
c22154
request.PathParameter("node-name"), } a.processAggregationRequest(key, request, response) }
c22155
NamespaceName: request.PathParameter("namespace-name"), } a.processAggregationRequest(key, request, response) }
c22156
ObjectType: core.MetricSetTypePodContainer, NamespaceName: request.PathParameter("namespace-name"), PodName: request.PathParameter("pod-name"), ContainerName: request.PathParameter("container-name"), } } a.processAggregationRequest(key, request, response) }
c22157
core.MetricSetTypeSystemContainer, NodeName: request.PathParameter("node-name"), ContainerName: request.PathParameter("container-name"), } a.processAggregationRequest(key, request, response) }
c22158
} keys = append(keys, key) } } metricName := request.PathParameter("metric-name") convertedMetricName := convertMetricName(metricName) var metrics map[core.HistoricalKey][]core.TimestampedAggregationValue if labels != nil { metrics, err = a.historicalSource.GetLabeledAggregation(convertedMetricName, labe...
c22159
err = a.historicalSource.GetLabeledMetric(convertedMetricName, labels, []core.HistoricalKey{key}, start, end) } else { metrics, err = a.historicalSource.GetMetric(convertedMetricName, []core.HistoricalKey{key}, start, end) } if err != nil { response.WriteError(http.StatusInternalServerError, err) return } ...
c22160
response.WriteError(http.StatusInternalServerError, err) } else { response.WriteEntity(resp) } }
c22161
multiplier = time.Second num = rawSize[:len(rawSize)-1] } else { multiplier = time.Millisecond num = rawSize[:len(rawSize)-2] } case 'h': multiplier = time.Hour num = rawSize[:len(rawSize)-1] case 'd': multiplier = 24 * time.Hour num = rawSize[:len(rawSize)-1] case 'm': multiplier = time.Mi...
c22162
aggName := core.AggregationType(aggNameRaw) if _, ok := core.AllAggregations[aggName]; !ok { return nil, fmt.Errorf("Unknown aggregation %q", aggName) } aggregations[ind] = aggName } return aggregations, nil }
c22163
floatVal := float64(value.FloatValue) return &types.MetricValue{ FloatValue: &floatVal, } } }
c22164
ok := aggregations.Aggregations[aggName]; ok { return exportMetricValue(&inputVal) } else { return nil } }
c22165
if val, ok := value.Aggregations[core.AggregationTypePercentile50]; ok { bucket.Percentiles["50"] = *exportMetricValue(&val) } if val, ok := value.Aggregations[core.AggregationTypePercentile95]; ok { bucket.Percentiles["95"] = *exportMetricValue(&val) } if val, ok := value.Aggregations[core.Aggregatio...
c22166
LabelHostname.Key: this.node.HostName, LabelHostID.Key: this.node.HostID, } this.decodeNodeStats(result, labels, &summary.Node) for _, pod := range summary.Pods { this.decodePodStats(result, labels, &pod) } glog.V(9).Infof("End summary decode") return result }
c22167
{ clone := make(map[string]string, len(labels)) for k, v := range labels { clone[k] = v } return clone }
c22168
ValueType: ValueInt64, MetricType: metric.Type, IntValue: int64(*value), } metrics.MetricValues[metric.Name] = val }
c22169
was nil", metric.Name, labels) return } val := LabeledMetric{ Name: metric.Name, Labels: labels, MetricValue: MetricValue{ ValueType: ValueInt64, MetricType: metric.Type, IntValue: int64(*value), }, } metrics.LabeledMetrics = append(metrics.LabeledMetrics, val) }
c22170
string { if legacyName, ok := systemNameMap[c.Name]; ok { return legacyName } return c.Name }
c22171
5 seconds timeout err := client.Connect(5) if err != nil { return nil, err } return client, nil }
c22172
glog.V(4).Infof("Exported %d events to riemann in %s", len(events), end.Sub(start)) return nil } else { glog.Warningf("There were errors sending events to Riemman, forcing reconnection. Error : %+v", err) return err } }
c22173
select { case sh.eventBatchChannel <- data: glog.V(2).Infof("Data events completed: %s", sh.sink.Name()) // everything ok case <-time.After(this.exportEventsTimeout): glog.Warningf("Failed to events data to sink: %s", sh.sink.Name()) } }(sh, &wg) } // Wait for all pushes to complete or time...
c22174
h.pushToCache(md.ID, hashDefinition(md)) }
c22175
hash: hash, ttl: h.runId, } h.regLock.Unlock() }
c22176
_, found := h.expReg[key] if !found || h.expReg[key].hash != hash { return false } // Update the TTL h.expReg[key].ttl = h.runId return true }
c22177
if (v.ttl + h.cacheAge) <= runId { delete(h.expReg, k) } } }
c22178
err := h.client.UpdateTags(p.Type, p.ID, p.Tags, h.modifiers...); err != nil { return err } } h.cache(p) } return nil }
c22179
a label that wasn't in our stored definition live.Tags[k] = v recent = false } } return recent }
c22180
len(l.Description) > 0 { tags[l.Key+descriptionTag] = l.Description } } if len(md.Units.String()) > 0 { tags[unitsTag] = md.Units.String() } tags[descriptorTag] = md.Name hmd := metrics.MetricDefinition{ ID: md.Name, Tags: tags, Type: heapsterTypeToHawkularType(md.Type), } return hmd }
c22181
} var value float64 if metric.ValueType == core.ValueInt64 { value = float64(metric.IntValue) } else { value = float64(metric.FloatValue) } m := metrics.Datapoint{ Value: value, Timestamp: timestamp, } mh := &metrics.MetricHeader{ ID: name, Data: []metrics.Datapoint{m}, Type: heapsterType...
c22182
regexp.Compile(proto[1]) if err != nil { return nil, err } fs = append(fs, labelFilter(proto[0], r)) break case Name: r, err := regexp.Compile(command) if err != nil { return nil, err } fs = append(fs, nameFilter(r)) break } } return fs, nil }
c22183
nil, st) case *tcell.EventKey: s.SetContent(w-2, h-2, ev.Rune(), nil, st) s.SetContent(w-1, h-1, 'K', nil, st) if ev.Key() == tcell.KeyEscape { ecnt++ if ecnt > 1 { s.Fini() os.Exit(0) } } else if ev.Key() == tcell.KeyCtrlL { s.Sync() } else { ecnt = 0 if ev.Rune() ==...
c22184
v.v.SetContent(x+v.physx, y+v.physy, ch, nil, style) } } } }
c22185
= 0 v.limy = 0 v.viewx = 0 v.viewy = 0 }
c22186
< v.limy && y >= v.viewy+v.height { v.viewy = y - (v.height - 1) } if y >= 0 && y < v.viewy { v.viewy = y } v.ValidateView() }
c22187
{ v.viewy = (v.limy - v.height) } if v.viewy < 0 { v.viewy = 0 } }
c22188
{ v.viewx = (v.limx - v.width) } if v.viewx < 0 { v.viewx = 0 } }
c22189
|| v.v == nil { return } v.viewx = x - (v.width / 2) v.viewy = y - (v.height / 2) v.ValidateView() }
c22190
-= rows v.ValidateViewY() }
c22191
+= rows v.ValidateViewY() }
c22192
-= cols v.ValidateViewX() }
c22193
+= cols v.ValidateViewX() }
c22194
height v.width = width v.ValidateView() }
c22195
v.viewy, v.viewx + v.width - 1, v.viewy + v.height - 1 }
c22196
v.physy, v.physx + v.width - 1, v.physy + v.height - 1 }
c22197
if height < 0 { height = py - y } if width <= x+px { v.width = width } if height <= y+py { v.height = height } }
c22198
= t.style } t.center.SetText(s) t.center.SetStyle(style) }
c22199
tcell.Style) { t.initialize() t.style = style }