id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1
value |
|---|---|---|
c167500 | watcher", "queue", w.name)
go w.loop()
} | |
c167501 | watcherSamplesSentPreTailing.DeleteLabelValues(w.name)
watcherCurrentSegment.DeleteLabelValues(w.name)
level.Info(w.logger).Log("msg", "WAL watcher stopped", "queue", w.name)
} | |
c167502 | {
if r >= index {
return r, nil
}
}
return -1, errors.New("failed to find segment for index")
} | |
c167503 | err)
} else if reader.Offset() != size {
level.Warn(w.logger).Log("msg", "expected to have read whole segment, may have dropped data", "segment", segmentNum, "read", reader.Offset(), "size", size)
}
return nil
}
// Otherwise, when we are tailing, non-EOFs are fatal.
if err != io.EOF {
re... | |
c167504 | if err != nil {
return errors.Wrap(err, "getSegmentSize")
}
sr, err := wal.OpenReadSegment(wal.SegmentName(checkpointDir, seg))
if err != nil {
return errors.Wrap(err, "unable to open segment")
}
defer sr.Close()
r := wal.NewLiveReader(w.logger, sr)
if err := w.readSegment(r, index, false); err ... | |
c167505 | os.Stat(wal.SegmentName(dir, index))
if err == nil {
i = fi.Size()
}
return i, err
} | |
c167506 | level.Info(zl.logger).Log("msg", fmt.Sprintf(s, i...))
} | |
c167507 | logger: logger,
}
tc.head = &zookeeperTreeCacheNode{
events: make(chan zk.Event),
children: map[string]*zookeeperTreeCacheNode{},
stopped: true,
}
go tc.loop(path)
return tc
} | |
c167508 | ctx: ctx,
updatert: 5 * time.Second,
triggerSend: make(chan struct{}, 1),
}
for _, option := range options {
option(mgr)
}
return mgr
} | |
c167509 | *Manager) {
m.mtx.Lock()
defer m.mtx.Unlock()
m.name = n
}
} | |
c167510 | m.cancelDiscoverers()
return m.ctx.Err()
}
return nil
} | |
c167511 | m.registerProviders(scfg, name)
discoveredTargets.WithLabelValues(m.name, name).Set(0)
}
for _, prov := range m.providers {
m.startProvider(m.ctx, prov)
}
return nil
} | |
c167512 | []string{name},
}
m.providers = append(m.providers, p)
m.startProvider(ctx, p)
} | |
c167513 | the consumer exits right away in which case
// the context will be canceled.
select {
case ch <- sd.TargetGroups:
case <-ctx.Done():
}
close(ch)
} | |
c167514 | NewDiscovery(conf.Servers, time.Duration(conf.Timeout), conf.Paths, logger, parseNerveMember)
} | |
c167515 | NewDiscovery(conf.Servers, time.Duration(conf.Timeout), conf.Paths, logger, parseServersetMember)
} | |
c167516 | conn,
updates: updates,
sources: map[string]*targetgroup.Group{},
parse: pf,
logger: logger,
}
for _, path := range paths {
sd.treeCaches = append(sd.treeCaches, treecache.NewZookeeperTreeCache(conn, path, updates, logger))
}
return sd, nil
} | |
c167517 |
if err == nil {
return fuzzInteresting
}
return fuzzMeh
} | |
c167518 |
if err == nil {
return fuzzInteresting
}
return fuzzMeh
} | |
c167519 |
if err == nil {
return fuzzInteresting
}
return fuzzMeh
} | |
c167520 | make(map[string]*config.ScrapeConfig),
scrapePools: make(map[string]*scrapePool),
graceShut: make(chan struct{}),
triggerReload: make(chan struct{}, 1),
}
} | |
c167521 | case m.triggerReload <- struct{}{}:
default:
}
case <-m.graceShut:
return nil
}
}
} | |
c167522 | labels.String()); err != nil {
return err
}
m.jitterSeed = h.Sum64()
return nil
} | |
c167523 |
for _, sp := range m.scrapePools {
sp.stop()
}
close(m.graceShut)
} | |
c167524 | delete(m.scrapePools, name)
} else if !reflect.DeepEqual(sp.config, cfg) {
err := sp.reload(cfg)
if err != nil {
level.Error(m.logger).Log("msg", "error reloading scrape pool", "err", err, "scrape_pool", name)
failed = true
}
}
}
if failed {
return errors.New("failed to apply the new configur... | |
c167525 |
targets[tset] = append(sp.ActiveTargets(), sp.DroppedTargets()...)
}
return targets
} | |
c167526 | sp := range m.scrapePools {
targets[tset] = sp.ActiveTargets()
}
return targets
} | |
c167527 | sp := range m.scrapePools {
targets[tset] = sp.DroppedTargets()
}
return targets
} | |
c167528 | if err != nil {
return "", err
}
hosts, err := net.LookupAddr(string(ip))
if err != nil || len(hosts) == 0 {
return "", err
}
return hosts[0], nil
}
for _, addr := range ips {
if ip := addr.To4(); ip != nil {
if fqdn, err := lookup(ip); err == nil {
return fqdn, nil
}
}
if ip := a... | |
c167529 |
for l, v := range m {
if l == model.MetricNameLabel {
continue
}
tags[string(l)] = TagValue(v)
}
return tags
} | |
c167530 |
}()
// API returns status code 204 for successful writes.
// http://opentsdb.net/docs/build/html/api_http/put.html
if resp.StatusCode == http.StatusNoContent {
return nil
}
// API returns status code 400 on error, encoding error details in the
// response content in JSON.
buf, err = ioutil.ReadAll(resp.Bod... | |
c167531 | return &querier{
ctx: ctx,
mint: mint,
maxt: maxt,
client: c,
}, nil
})
} | |
c167532 | defer remoteReadGauge.Dec()
res, err := q.client.Read(q.ctx, query)
if err != nil {
return nil, nil, err
}
return FromQueryResult(res), nil, nil
} | |
c167533 | != nil {
return nil, err
}
return &externalLabelsQuerier{Querier: q, externalLabels: externalLabels}, nil
})
} | |
c167534 | err := q.Querier.Select(p, m...)
if err != nil {
return nil, warnings, err
}
return newSeriesSetFilter(s, added), warnings, nil
} | |
c167535 | {
return storage.NoopQuerier(), nil
}
// Query only samples older than the first timestamp in local DB.
if maxt > localStartTime {
cmaxt = localStartTime
}
return next.Querier(ctx, mint, cmaxt)
})
} | |
c167536 | != nil {
return nil, err
}
return &requiredMatchersQuerier{Querier: q, requiredMatchers: required}, nil
})
} | |
c167537 | }
}
if len(ms) == 0 {
break
}
}
if len(ms) > 0 {
return storage.NoopSeriesSet(), nil, nil
}
return q.Querier.Select(p, matchers...)
} | |
c167538 |
continue
}
i++
}
}
for _, l := range el {
m, err := labels.NewMatcher(labels.MatchEqual, l.Name, l.Value)
if err != nil {
panic(err)
}
ms = append(ms, m)
}
return ms, el
} | |
c167539 | &InstanceDiscovery{provider: provider, authOpts: opts,
region: region, port: port, allTenants: allTenants, logger: l}
} | |
c167540 |
if a.EndsAt.IsZero() {
return false
}
return !a.EndsAt.After(ts)
} | |
c167541 | float64 { return float64(n.queueLen()) }
alertmanagersDiscoveredFunc := func() float64 { return float64(len(n.Alertmanagers())) }
n.metrics = newAlertMetrics(
o.Registerer,
o.QueueCapacity,
queueLenFunc,
alertmanagersDiscoveredFunc,
)
return n
} | |
c167542 | n.metrics
// The config hash is used for the map lookup identifier.
b, err := json.Marshal(cfg)
if err != nil {
return err
}
amSets[fmt.Sprintf("%x", md5.Sum(b))] = ams
}
n.alertmanagers = amSets
return nil
} | |
c167543 | n.metrics.dropped.Add(float64(len(alerts)))
}
// If the queue still has items left, kick off the next iteration.
if n.queueLen() > 0 {
n.setMore()
}
}
} | |
c167544 | n.metrics.dropped.Add(float64(d))
}
// If the queue is full, remove the oldest alerts in favor
// of newer ones.
if d := (len(n.queue) + len(alerts)) - n.opts.QueueCapacity; d > 0 {
n.queue = n.queue[d:]
level.Warn(n.logger).Log("msg", "Alert notification queue full, dropping alerts", "num_dropped", d)
n.m... | |
c167545 | am := range ams.ams {
res = append(res, am.url())
}
ams.mtx.RUnlock()
}
return res
} | |
c167546 | dam := range ams.droppedAms {
res = append(res, dam.url())
}
ams.mtx.RUnlock()
}
return res
} | |
c167547 | != nil {
level.Error(n.logger).Log("alertmanager", u, "count", len(alerts), "msg", "Error sending alert", "err", err)
n.metrics.errors.WithLabelValues(u).Inc()
} else {
atomic.AddUint64(&numSuccess, 1)
}
n.metrics.latency.WithLabelValues(u).Observe(time.Since(begin).Seconds())
n.metrics.... | |
c167548 | "Stopping notification manager...")
n.cancel()
} | |
c167549 | := map[string]struct{}{}
for _, am := range allAms {
us := am.url().String()
if _, ok := seen[us]; ok {
continue
}
// This will initialize the Counters for the AM to 0.
s.metrics.sent.WithLabelValues(us)
s.metrics.errors.WithLabelValues(us)
seen[us] = struct{}{}
s.ams = append(s.ams, am)
}
} | |
c167550 | addr := lset.Get(model.AddressLabel)
// If it's an address with no trailing port, infer it based on the used scheme.
if addPort(addr) {
// Addresses reaching this point are already wrapped in [] if necessary.
switch lset.Get(model.SchemeLabel) {
case "http", "":
addr = addr + ":80"
case "https":
... | |
c167551 | case i.typ.isAggregator():
return fmt.Sprintf("<aggr:%s>", i.val)
case len(i.val) > 10:
return fmt.Sprintf("%.10q...", i.val)
}
return fmt.Sprintf("%q", i.val)
} | |
c167552 | == ItemCountValues || i == ItemQuantile
} | |
c167553 | ItemGTE, ItemGTR:
return true
default:
return false
}
} | |
c167554 | ItemLOR, ItemLUnless:
return true
}
return false
} | |
c167555 | ItemMUL, ItemDIV, ItemMOD:
return 5
case ItemPOW:
return 6
default:
return LowestPrec
}
} | |
c167556 | := utf8.DecodeRuneInString(l.input[l.pos:])
l.width = Pos(w)
l.pos += l.width
return r
} | |
c167557 | l.next()
l.backup()
return r
} | |
c167558 | <- item{t, l.start, l.input[l.start:l.pos]}
l.start = l.pos
} | |
c167559 | return 1 + int(l.lastPos)
}
return 1 + int(l.lastPos) - lb
} | |
c167560 | := <-l.items
l.lastPos = item.pos
return item
} | |
c167561 |
input: input,
items: make(chan item),
}
go l.run()
return l
} | |
c167562 | return l.errorf("unexpected character after '!' inside braces: %q", nr)
}
case r == '{':
return l.errorf("unexpected left brace %q", r)
case r == '}':
l.emit(ItemRightBrace)
l.braceOpen = false
if l.seriesDesc {
return lexValueSequence
}
return lexStatements
default:
return l.errorf("unexpected ... | |
c167563 | items here but this will be caught by the parser.
return lexKeywordOrIdentifier
default:
return l.errorf("unexpected character in series sequence: %q", r)
}
return lexValueSequence
} | |
c167564 | && ch <= 'F':
return int(ch - 'A' + 10)
}
return 16 // Larger than any legal digit val.
} | |
c167565 | return l.errorf("unterminated quoted string")
case l.stringOpen:
break Loop
}
}
l.emit(ItemString)
return lexStatements
} | |
c167566 | {
l.next()
}
l.ignore()
return lexStatements
} | |
c167567 | r = l.next()
}
l.backup()
l.emit(ItemComment)
return lexStatements
} | |
c167568 | }
l.backup()
l.emit(ItemDuration)
return lexStatements
}
return l.errorf("bad number or duration syntax: %q", l.input[l.start:l.pos])
} | |
c167569 |
l.acceptRun(digits)
if l.accept(".") {
l.acceptRun(digits)
}
if l.accept("eE") {
l.accept("+-")
l.acceptRun("0123456789")
}
// Next thing must not be alphanumeric unless it's the times token
// for series repetitions.
if r := l.peek(); (l.seriesDesc && r == 'x') || !isAlphaNumeric(r) {
return true
}
... | |
c167570 |
l.emit(ItemIdentifier)
return lexStatements
} | |
c167571 | l.emit(ItemMetricIdentifier)
}
break Loop
}
}
if l.seriesDesc && l.peek() != '{' {
return lexValueSequence
}
return lexStatements
} | |
c167572 | return false
}
for _, c := range s[1:] {
if !isAlphaNumeric(c) {
return false
}
}
return true
} | |
c167573 | &p.ts, p.val
}
return p.series, nil, p.val
} | |
c167574 | {
return p.l.b[p.offsets[0]:p.offsets[1]], p.mtype
} | |
c167575 | tWhitespace {
return tok
}
}
} | |
c167576 | QueryEngine: qe,
Queryable: q,
targetRetriever: tr,
alertmanagerRetriever: ar,
now: time.Now,
config: configFunc,
flagsMap: flagsMap,
ready: readyFunc,
db: db,
enableAdmin: enableAd... | |
c167577 | append(result, primary[i])
i++
j++
}
}
for ; i < len(primary); i++ {
result = append(result, primary[i])
}
for ; j < len(secondary); j++ {
result = append(result, secondary[j])
}
return result
} | |
c167578 | &adapter{db: db, startTimeMargin: startTimeMargin}
} | |
c167579 |
return x.db
}
return nil
} | |
c167580 | nil {
return x.Querier(ctx, mint, maxt)
}
return nil, ErrNotReady
} | |
c167581 | {
return x.Appender()
}
return nil, ErrNotReady
} | |
c167582 | return x.Close()
}
return nil
} | |
c167583 | db, startTimeMargin: startTimeMargin}
} | |
c167584 | err := tsdb.Open(path, l, r, &tsdb.Options{
WALSegmentSize: int(opts.WALSegmentSize),
RetentionDuration: uint64(time.Duration(opts.RetentionDuration).Seconds() * 1000),
MaxBytes: int64(opts.MaxBytes),
BlockRanges: rngs,
NoLockfile: opts.NoLockfile,
AllowOve... | |
c167585 | appender{a: a.db.Appender()}, nil
} | |
c167586 |
return Regexp{
Regexp: regex,
original: s,
}, err
} | |
c167587 | err != nil {
panic(err)
}
return re
} | |
c167588 | relabel(labels, cfg)
if labels == nil {
return nil
}
}
return labels
} | |
c167589 | i - 1) * 8)
s |= uint64(b) << shift
}
return s
} | |
c167590 | wg.Done()
}(l)
delete(sp.loops, fp)
delete(sp.activeTargets, fp)
}
wg.Wait()
sp.client.CloseIdleConnections()
} | |
c167591 | sp.config.HonorLabels
honorTimestamps = sp.config.HonorTimestamps
mrc = sp.config.MetricRelabelConfigs
)
for fp, oldLoop := range sp.loops {
var (
t = sp.activeTargets[fp]
s = &targetScraper{Target: t, client: sp.client, timeout: timeout}
newLoop = sp.newLoop(scrapeLoopOptions... | |
c167592 | } else if t.DiscoveredLabels().Len() > 0 {
sp.droppedTargets = append(sp.droppedTargets, t)
}
}
}
sp.mtx.Unlock()
sp.sync(all)
targetSyncIntervalLength.WithLabelValues(sp.config.JobName).Observe(
time.Since(start).Seconds(),
)
targetScrapePoolSyncsCounter.WithLabelValues(sp.config.JobName).Inc()
} | |
c167593 | and scraper loops.
for hash := range sp.activeTargets {
if _, ok := uniqueTargets[hash]; !ok {
wg.Add(1)
go func(l loop) {
l.stop()
wg.Done()
}(sp.loops[hash])
delete(sp.loops, hash)
delete(sp.activeTargets, hash)
}
}
// Wait for all potentially stopped scrapers to terminate.
// This... | |
c167594 | }
// The limit is applied after metrics are potentially dropped via relabeling.
if limit > 0 {
app = &limitAppender{
Appender: app,
limit: limit,
}
}
return app
} | |
c167595 | " + charsToString(buf.Machine[:])
str += " " + charsToString(buf.Nodename[:])
str += " " + charsToString(buf.Domainname[:]) + ")"
return str
} | |
c167596 | return nil, err
}
reqBuf, err := snappy.Decode(nil, compressed)
if err != nil {
return nil, err
}
var req prompb.ReadRequest
if err := proto.Unmarshal(reqBuf, &req); err != nil {
return nil, err
}
return &req, nil
} | |
c167597 | err
}
w.Header().Set("Content-Type", "application/x-protobuf")
w.Header().Set("Content-Encoding", "snappy")
compressed := snappy.Encode(nil, data)
_, err = w.Write(compressed)
return err
} | |
c167598 | p.End,
}
}
return &prompb.Query{
StartTimestampMs: from,
EndTimestampMs: to,
Matchers: ms,
Hints: rp,
}, nil
} | |
c167599 | req.Hints.StartMs,
End: req.Hints.EndMs,
Step: req.Hints.StepMs,
Func: req.Hints.Func,
}
}
return req.StartTimestampMs, req.EndTimestampMs, matchers, selectParams, nil
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.