id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1
value |
|---|---|---|
c167400 | := errors.Errorf("invalid ID '%s'. Refusing to create azureResource", id)
level.Error(logger).Log("err", err)
return azureResource{}, err
}
return azureResource{
Name: strings.ToLower(s[8]),
ResourceGroup: strings.ToLower(s[4]),
}, nil
} | |
c167401 | %s", t.name, t.duration)
} | |
c167402 | t[i], t[j] = t[j], t[i]
} | |
c167403 | := &bytes.Buffer{}
for _, timer := range timers.Timers {
fmt.Fprintf(result, "%s\n", timer)
}
return result.String()
} | |
c167404 |
return RegisterAdminHandlerClient(ctx, mux, NewAdminClient(conn))
} | |
c167405 |
return nil, err
}
err = p.typecheck(expr)
return expr, err
} | |
c167406 |
m = p.metric()
if p.peek().typ != ItemEOF {
p.errorf("could not parse remaining input %.15q...", p.lex.input[p.lex.lastPos:])
}
return m, nil
} | |
c167407 | p.peek().typ != ItemEOF {
p.errorf("could not parse remaining input %.15q...", p.lex.input[p.lex.lastPos:])
}
return vs.LabelMatchers, nil
} | |
c167408 | {
p := &parser{
lex: lex(input),
}
return p
} | |
c167409 | remaining input %.15q...", p.lex.input[p.lex.lastPos:])
}
expr = p.expr()
}
if expr == nil {
p.errorf("no expression found in input")
}
return
} | |
c167410 | error) {
p := newParser(input)
p.lex.seriesDesc = true
return p.parseSeriesDesc()
} | |
c167411 |
p.checkType(node)
return nil
} | |
c167412 |
}
if p.token[p.peekCount].typ == ItemError {
p.errorf("%s", p.token[p.peekCount].val)
}
return p.token[p.peekCount]
} | |
c167413 | 1
t := p.lex.nextItem()
// Skip comments.
for t.typ == ItemComment {
t = p.lex.nextItem()
}
p.token[0] = t
return p.token[0]
} | |
c167414 | ...interface{}) {
p.error(errors.Errorf(format, args...))
} | |
c167415 |
if strings.Count(strings.TrimSpace(p.lex.input), "\n") == 0 {
perr.Line = 0
}
panic(perr)
} | |
c167416 | %s, expected %s", token.desc(), context, exp.desc())
}
return token
} | |
c167417 | p.errorf("unexpected %s in %s, expected %s or %s", token.desc(), context, exp1.desc(), exp2.desc())
}
return token
} | |
c167418 |
buf := make([]byte, 64<<10)
buf = buf[:runtime.Stack(buf, false)]
fmt.Fprintf(os.Stderr, "parser panic: %v\n%s", e, buf)
*errp = errUnexpected
} else if e != nil {
*errp = e.(error)
}
p.lex.close()
} | |
c167419 | ItemGroupLeft {
vecMatching.Card = CardManyToOne
} else {
vecMatching.Card = CardOneToMany
}
if p.peek().typ == ItemLeftParen {
vecMatching.Include = p.labels()
}
}
}
for _, ln := range vecMatching.MatchingLabels {
for _, ln2 := range vecMatching.Include {
if ln == ln2 && ... | |
c167420 | if err != nil {
f, err = strconv.ParseFloat(val, 64)
}
if err != nil {
p.errorf("error parsing number: %s", err)
}
return f
} | |
c167421 | type %s in %s, got %s", documentedType(want), context, documentedType(t))
}
} | |
c167422 | ×tampTracker{
storage: s,
}, nil
} | |
c167423 | error) {
t.samples++
if ts > t.highestTimestamp {
t.highestTimestamp = ts
}
return 0, nil
} | |
c167424 | uint64, ts int64, v float64) error {
_, err := t.Add(l, ts, v)
return err
} | |
c167425 | highestTimestamp.Set(float64(t.highestTimestamp / 1000))
return nil
} | |
c167426 | {
*p = append(*p, Problem{
Metric: mf.GetName(),
Text: text,
})
} | |
c167427 | append(problems, lint(mf)...)
}
// Ensure deterministic output.
sort.SliceStable(problems, func(i, j int) bool {
if problems[i].Metric < problems[j].Metric {
return true
}
return problems[i].Text < problems[j].Text
})
return problems, nil
} | |
c167428 | problems = append(problems, fn(mf)...)
}
// TODO(mdlayher): lint rules for specific metrics types.
return problems
} | |
c167429 | mf.Help == nil {
problems.Add(mf, "no help text")
}
return problems
} | |
c167430 |
if unit == base {
return nil
}
problems.Add(mf, fmt.Sprintf("use base unit %q instead of %q", base, unit))
return problems
} | |
c167431 | suffix`)
case !isUntyped && !isCounter && hasTotalSuffix:
problems.Add(mf, `non-counter metrics should not have "_total" suffix`)
}
return problems
} | |
c167432 | math.IsInf(v, 0) {
level.Debug(c.logger).Log("msg", "cannot send value to Graphite, skipping sample", "value", v, "sample", s)
continue
}
fmt.Fprintf(&buf, "%s %f %f\n", k, v, t)
}
_, err = conn.Write(buf.Bytes())
return err
} | |
c167433 | }
if factor < 1 {
panic("invalid factor")
}
var sizes []int
for s := minSize; s <= maxSize; s = int(float64(s) * factor) {
sizes = append(sizes, s)
}
p := &Pool{
buckets: make([]sync.Pool, len(sizes)),
sizes: sizes,
make: makeFunc,
}
return p
} | |
c167434 | nil {
b = p.make(bktSize)
}
return b
}
return p.make(sz)
} | |
c167435 | slice.Cap() > size {
continue
}
p.buckets[i].Put(slice.Slice(0, 0).Interface())
return
}
} | |
c167436 | += len(series.Points)
}
return numSamples
} | |
c167437 | }
v, ok := r.Value.(Vector)
if !ok {
return nil, errors.New("query result is not a Vector")
}
return v, nil
} | |
c167438 | }
v, ok := r.Value.(Scalar)
if !ok {
return Scalar{}, errors.New("query result is not a Scalar")
}
return v, nil
} | |
c167439 |
profile: conf.Profile,
roleARN: conf.RoleARN,
filters: conf.Filters,
interval: time.Duration(conf.RefreshInterval),
port: conf.Port,
}
d.Discovery = refresh.NewDiscovery(
logger,
"ec2",
time.Duration(conf.RefreshInterval),
d.refresh,
)
return d
} | |
c167440 |
relabelConfigs: relabelConfigs,
client: client,
seriesLabels: make(map[uint64][]prompb.Label),
seriesSegmentIndexes: make(map[uint64]int),
droppedSeries: make(map[uint64]struct{}),
numShards: cfg.MinShards,
reshardChan: make(chan int),
quit: make(chan struct{}),
sam... | |
c167441 | },
},
ref: sample.Ref,
})
}
t.seriesMtx.Unlock()
outer:
for _, sample := range tempSamples {
// This will only loop if the queues are being resharded.
backoff := t.cfg.MinBackoff
for {
select {
case <-t.quit:
return false
default:
}
if t.shards.enqueue(sample.ref, sample.ts) {
... | |
c167442 |
t.succeededSamplesTotal = succeededSamplesTotal.WithLabelValues(name)
t.retriedSamplesTotal = retriedSamplesTotal.WithLabelValues(name)
t.shardCapacity = shardCapacity.WithLabelValues(name)
// Initialise some metrics.
t.shardCapacity.Set(float64(t.cfg.Capacity))
t.pendingSamplesMetric.Set(0)
t.shards.start(t.... | |
c167443 | for queues that are gone.
name := t.client.Name()
queueHighestSentTimestamp.DeleteLabelValues(name)
queuePendingSamples.DeleteLabelValues(name)
enqueueRetriesTotal.DeleteLabelValues(name)
droppedSamplesTotal.DeleteLabelValues(name)
numShards.DeleteLabelValues(name)
failedSamplesTotal.DeleteLabelValues(name)
se... | |
c167444 | ref, labels := range temp {
t.seriesSegmentIndexes[ref] = index
// We should not ever be replacing a series labels in the map, but just
// in case we do we need to ensure we do not leak the replaced interned
// strings.
if orig, ok := t.seriesLabels[ref]; ok {
release(orig)
}
t.seriesLabels[ref] = la... | |
c167445 |
} else {
result = append(result, labels.Label{
Name: ls[i].Name,
Value: ls[i].Value,
})
i++
j++
}
}
for ; i < len(ls); i++ {
result = append(result, labels.Label{
Name: ls[i].Name,
Value: ls[i].Value,
})
}
result = append(result, externalLabels[j:]...)
return result
} | |
c167446 |
var hardShutdownCtx context.Context
hardShutdownCtx, s.hardShutdown = context.WithCancel(context.Background())
s.softShutdown = make(chan struct{})
s.running = int32(n)
s.done = make(chan struct{})
for i := 0; i < n; i++ {
go s.runShard(hardShutdownCtx, i, newQueues[i])
}
s.qm.numShardsMetric.Set(float64(n)... | |
c167447 | closed channel.
s.mtx.Lock()
defer s.mtx.Unlock()
for _, queue := range s.queues {
close(queue)
}
select {
case <-s.done:
return
case <-time.After(s.qm.flushDeadline):
level.Error(s.qm.logger).Log("msg", "Failed to flush all samples on shutdown")
}
// Force an unclean shutdown.
s.hardShutdown()
<-s.d... | |
c167448 | return false
default:
}
shard := uint64(ref) % uint64(len(s.queues))
select {
case <-s.softShutdown:
return false
case s.queues[shard] <- sample:
return true
}
} | |
c167449 | return nil
}
if _, ok := err.(recoverableError); !ok {
return err
}
s.qm.retriedSamplesTotal.Add(float64(len(samples)))
level.Debug(s.qm.logger).Log("msg", "failed to send batch, retrying", "err", err)
time.Sleep(time.Duration(backoff))
backoff = backoff * 2
if backoff > s.qm.cfg.MaxBackoff {
b... | |
c167450 | via in-cluster config")
} else {
rt, err := config_util.NewRoundTripperFromConfig(conf.HTTPClientConfig, "kubernetes_sd")
if err != nil {
return nil, err
}
kcfg = &rest.Config{
Host: conf.APIServer.String(),
Transport: rt,
}
}
kcfg.UserAgent = "Prometheus/discovery"
c, err := kubernetes.N... | |
c167451 | nil {
return nil, err
}
return r.Regexp, nil
} | |
c167452 | hostname, port)
}
if startsOrEndsWithQuote(u) {
return nil, errors.New("URL must not begin or end with quotes")
}
eu, err := url.Parse(u)
if err != nil {
return nil, err
}
ppref := strings.TrimRight(eu.Path, "/")
if ppref != "" && !strings.HasPrefix(ppref, "/") {
ppref = "/" + ppref
}
eu.Path = ppre... | |
c167453 |
if !alert.ResolvedAt.IsZero() {
a.EndsAt = alert.ResolvedAt
} else {
a.EndsAt = alert.ValidUntil
}
res = append(res, a)
}
if len(alerts) > 0 {
s.Send(res...)
}
}
} | |
c167454 | err := range r.Validate() {
var ruleName string
if r.Alert != "" {
ruleName = r.Alert
} else {
ruleName = r.Record
}
errs = append(errs, &Error{
Group: g.Name,
Rule: i,
RuleName: ruleName,
Err: err,
})
}
}
}
return errs
} | |
c167455 | if !model.LabelName(k).IsValid() {
errs = append(errs, errors.Errorf("invalid label name: %s", k))
}
if !model.LabelValue(v).IsValid() {
errs = append(errs, errors.Errorf("invalid label value: %s", v))
}
}
for k := range r.Annotations {
if !model.LabelName(k).IsValid() {
errs = append(errs, errors... | |
c167456 | return nil, []error{err}
}
return &groups, groups.Validate()
} | |
c167457 | return nil, []error{err}
}
return Parse(b)
} | |
c167458 | fmt.Sprintf("/graph?g0.expr=%s&g0.tab=1", escapedExpression)
} | |
c167459 | fmt.Sprintf("/graph?g0.expr=%s&g0.tab=0", escapedExpression)
} | |
c167460 | {
return &fanout{
logger: logger,
primary: primary,
secondaries: secondaries,
}
} | |
c167461 | errors?
var lastErr error
for _, storage := range f.secondaries {
if err := storage.Close(); err != nil {
lastErr = err
}
}
return lastErr
} | |
c167462 | return NoopQuerier()
case 1:
return filtered[0]
default:
return &mergeQuerier{
primaryQuerier: primaryQuerier,
queriers: filtered,
failedQueriers: failedQueriers,
setQuerierMap: setQuerierMap,
}
}
} | |
c167463 | the error source isn't the primary querier, return the error as a warning and continue.
if querier != q.primaryQuerier {
warnings = append(warnings, err)
continue
} else {
return nil, nil, err
}
}
seriesSets = append(seriesSets, set)
}
return NewMergeSeriesSet(seriesSets, q), warnings, nil
} | |
c167464 | nil, err
}
results = append(results, values)
}
return mergeStringSlices(results), nil
} | |
c167465 | Querier")
}
for _, name := range names {
labelNamesMap[name] = struct{}{}
}
}
labelNames := make([]string, 0, len(labelNamesMap))
for name := range labelNamesMap {
labelNames = append(labelNames, name)
}
sort.Strings(labelNames)
return labelNames, nil
} | |
c167466 |
if err := querier.Close(); err != nil {
lastErr = err
}
}
return lastErr
} | |
c167467 | vec,
holdDuration: hold,
labels: labels,
annotations: annotations,
externalLabels: el,
health: HealthUnknown,
active: map[uint64]*Alert{},
logger: logger,
restored: restored,
}
} | |
c167468 | defer r.mtx.Unlock()
r.lastError = err
} | |
c167469 | defer r.mtx.Unlock()
return r.lastError
} | |
c167470 | defer r.mtx.Unlock()
r.health = health
} | |
c167471 | defer r.mtx.Unlock()
return r.health
} | |
c167472 | lb.Set(labels.MetricName, alertForStateMetricName)
lb.Set(labels.AlertName, r.name)
s := promql.Sample{
Metric: lb.Labels(),
Point: promql.Point{T: timestamp.FromTime(ts), V: v},
}
return s
} | |
c167473 | defer r.mtx.Unlock()
r.evaluationDuration = dur
} | |
c167474 | defer r.mtx.Unlock()
return r.evaluationDuration
} | |
c167475 | {
if a.State > maxState {
maxState = a.State
}
}
return maxState
} | |
c167476 | a.ResolvedAt.IsZero() {
res = append(res, a)
}
}
return res
} | |
c167477 | := range r.active {
anew := *a
alerts = append(alerts, &anew)
}
return alerts
} | |
c167478 | if err != nil {
level.Error(log.With(a.logger, "component", "sd-adapter")).Log("err", err)
}
}
} | |
c167479 |
_, err = tmpfile.Write(b)
if err != nil {
return err
}
err = os.Rename(tmpfile.Name(), a.output)
if err != nil {
return err
}
return nil
} | |
c167480 | a.name, a.disc)
go a.runCustomSD(a.ctx)
} | |
c167481 | groups: make(map[string]*customSD),
manager: discovery.NewManager(ctx, logger),
output: file,
name: name,
logger: logger,
}
} | |
c167482 | namespace,
Name: "rule_group_iterations_missed_total",
Help: "The total number of rule group evaluations missed due to slow rule group evaluation.",
}),
iterationsScheduled: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "rule_group_iterations_total",
Help: ... | |
c167483 | return v, nil
case promql.Scalar:
return promql.Vector{promql.Sample{
Point: promql.Point(v),
Metric: labels.Labels{},
}}, nil
default:
return nil, errors.New("rule result is not a vector or scalar")
}
}
} | |
c167484 | rules,
shouldRestore: shouldRestore,
opts: opts,
seriesInPreviousEval: make([]map[string]labels.Labels, len(rules)),
done: make(chan struct{}),
terminated: make(chan struct{}),
logger: log.With(opts.Logger, "group", name),
metrics: ... | |
c167485 | defer g.mtx.Unlock()
return g.evaluationDuration
} | |
c167486 | g.name)).Set(dur.Seconds())
g.mtx.Lock()
defer g.mtx.Unlock()
g.evaluationDuration = dur
} | |
c167487 | defer g.mtx.Unlock()
return g.evaluationTimestamp
} | |
c167488 | 1e9)
g.mtx.Lock()
defer g.mtx.Unlock()
g.evaluationTimestamp = ts
} | |
c167489 | = adjNow - (adjNow % int64(g.interval))
)
return time.Unix(0, base+offset)
} | |
c167490 | g.seriesInPreviousEval[i] = from.seriesInPreviousEval[fi]
ruleMap[nameAndLabels] = indexes[1:]
ar, ok := rule.(*AlertingRule)
if !ok {
continue
}
far, ok := from.rules[fi].(*AlertingRule)
if !ok {
continue
}
for fp, a := range far.active {
ar.active[fp] = a
}
}
} | |
c167491 | }
if o.Registerer != nil {
o.Registerer.MustRegister(m)
}
o.Metrics.iterationsMissed.Inc()
return m
} | |
c167492 | range m.groups {
eg.stop()
}
level.Info(m.logger).Log("msg", "Rule manager stopped")
} | |
c167493 | newg.CopyState(oldg)
}
go func() {
// Wait with starting evaluation until the rule manager
// is told to run. This is necessary to avoid running
// queries against a bootstrapping storage.
<-m.block
newg.run(m.opts.Context)
}()
wg.Done()
}(newg)
}
// Stop remaining old groups.
for... | |
c167494 | expr,
time.Duration(r.For),
labels.FromMap(r.Labels),
labels.FromMap(r.Annotations),
externalLabels,
m.restored,
log.With(m.logger, "alert", r.Alert),
))
continue
}
rules = append(rules, NewRecordingRule(
r.Record,
expr,
labels.FromMap(r.Labels),
... | |
c167495 | func(i, j int) bool {
if rgs[i].file != rgs[j].file {
return rgs[i].file < rgs[j].file
}
return rgs[i].name < rgs[j].name
})
return rgs
} | |
c167496 |
var rules []Rule
for _, g := range m.groups {
rules = append(rules, g.rules...)
}
return rules
} | |
c167497 | if alertingRule, ok := rule.(*AlertingRule); ok {
alerts = append(alerts, alertingRule)
}
}
return alerts
} | |
c167498 |
ch <- prometheus.MustNewConstMetric(groupInterval,
prometheus.GaugeValue,
g.interval.Seconds(),
groupKey(g.file, g.name))
}
} | |
c167499 | }
return &WALWatcher{
logger: logger,
writer: writer,
walDir: path.Join(walDir, "wal"),
name: name,
quit: make(chan struct{}),
done: make(chan struct{}),
maxSegment: -1,
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.