-
.bingo
- .gitignore
- README.md
- Variables.mk
- alertmanager.mod
- alertmanager.sum
- bingo.mod
- bingo.sum
- faillint.mod
- faillint.sum
- go.mod
- go.sum
- goimports.mod
- goimports.sum
- gojsontoyaml.mod
- gojsontoyaml.sum
- golangci-lint.mod
- golangci-lint.sum
- gotesplit.mod
- gotesplit.sum
- hugo.mod
- hugo.sum
- jb.mod
- jb.sum
- jsonnet-lint.mod
- jsonnet-lint.sum
- jsonnet.mod
- jsonnet.sum
- jsonnetfmt.mod
- jsonnetfmt.sum
- mdox.mod
- mdox.sum
- minio.mod
- minio.sum
- promdoc.mod
- promdoc.sum
- prometheus.mod
- prometheus.sum
- promtool.mod
- promtool.sum
- promu.mod
- promu.sum
- protoc-gen-gogofast.mod
- protoc-gen-gogofast.sum
- shfmt.mod
- shfmt.sum
- variables.env
- .circleci
- .devcontainer
- .github
- cmd
-
docs
- blog
- components
- contributing
-
img
- Thanos-logo_full.svg
- Thanos-logo_fullmedium.png
- Thanos_with_cilium.png
- bottleneck-globalsort.png
- bucket-web.jpg
- compaction_progress_metrics.png
- distributed-execution-proposal-1.png
- distributed-execution-proposal-2.png
- distributed-execution-proposal-3.png
- distributed-execution-proposal-4.png
- distributed-execution-proposal-5.png
- distributed-execution-proposal-6.png
- get-ref-map.png
- globalsort-nonoptimized.png
- globalsort-optimized.png
- go-in-thanos.jpg
- groupcache.png
- hubble_network_flow.png
- latency-with-sharding.png
- latency-without-sharding.png
- memory-with-sharding.png
- memory-without-sharding.png
- meta-monitoring-validator.png
- per-receive.png
- querier.svg
- query-path-tenancy-proposal-diagram.svg
- query_ui_6week.png
- query_ui_6week_dedup.png
- query_ui_stores.png
- receive-validator.png
- rueidis-client-side.png
- thanos_log_limit.png
- thanos_proposal_flow.excalidraw
- thanos_proposal_flow.png
- thanos_receiver_troubleshoot_empty_replica_external_label_name.drawio.png
- thanos_receiver_troubleshoot_federation_idential_replica_name.drawio.png
- thanos_receiver_troubleshoot_grafana_remote_write.png
- thanos_receiver_troubleshoot_no_external_labels.drawio.png
- tracing.png
- tracing2.png
- vertical-sharding.png
- zoomedit.png
- zoomrecording.png
- operating
-
proposals-accepted
- 202012-deletions-object-storage.md
- 202012-receive-split.md
- 202101-endpoint-discovery.md
- 202106-automated-per-endpoint-mTLS.md
- 202107-protobuf-openapi-httpapi.md
- 202108-more-granular-query-performance-metrics.md
- 202205-vertical-query-sharding.md
- 202206-active-series-limiting-hashring.md
- 202209-receive-tenant-external-labels.md
- 20221129-avoid-global-sort.md
- 202301-distributed-query-execution.md
- 202304-query-path-tenancy.md
- README.md
-
proposals-done
- 201809-gossip-removal.md
- 201812-thanos-remote-receive.md
- 201901-read-write-operations-bucket.md
- 201909-thanos-sharding.md
- 201912-thanos-binary-index-header.md
- 202001-thanos-query-health-handling.md
- 202003-thanos-rules-federation.md
- 202004-embedd-cortex-frontend.md
- 202005-query-logging.md
- 202005-scalable-rule-storage.md
- 202005-version-documentation.md
- 202106-proposals-process.md
- 202203-grpc-query-api.md
- README.md
- proposals-rejected
- support
- README.md
- design.md
- getting-started.md
- governance.md
- integrations.md
- logging.md
- quick-tutorial.md
- release-process.md
- service-discovery.md
- sharding.md
- storage.md
- tracing.md
- examples
-
internal
-
cortex
-
chunk
-
cache
- background.go
- background_extra_test.go
- background_test.go
- cache.go
- cache_gen.go
- cache_gen_test.go
- cache_test.go
- fifo_cache.go
- fifo_cache_test.go
- instrumented.go
- memcached.go
- memcached_client.go
- memcached_client_selector.go
- memcached_client_test.go
- memcached_test.go
- mock.go
- redis_cache.go
- redis_cache_test.go
- redis_client.go
- redis_client_test.go
- snappy.go
- tiered.go
- tiered_test.go
-
cache
- cortexpb
- frontend
-
querier
-
queryrange
- compat.go
- instrumentation.go
- limits.go
- limits_test.go
- marshaling_test.go
- query_range.go
- query_range_test.go
- queryrange.pb.go
- queryrange.proto
- results_cache.go
- results_cache_test.go
- retry.go
- retry_test.go
- roundtrip.go
- roundtrip_test.go
- split_by_interval.go
- split_by_interval_test.go
- step_align.go
- step_align_test.go
- util.go
- series
- stats
- querier.go
-
queryrange
- tenant
- util
-
chunk
-
cortex
- mixin
-
pkg
- alert
- api
- block
- cache
- cacheutil
- clientconfig
- compact
- compactv2
- component
- dedup
- discovery
- errors
- errutil
- exemplars
- extannotations
- extflag
- extgrpc
- exthttp
- extkingpin
- extprom
- gate
- info
- logging
- metadata
- model
- pool
- prober
- promclient
- query
-
queryfrontend
- cache.go
- cache_test.go
- config.go
- config_test.go
- downsampled.go
- downsampled_test.go
- labels_codec.go
- labels_codec_test.go
- queryinstant_codec.go
- queryinstant_codec_test.go
- queryrange_codec.go
- queryrange_codec_test.go
- request.go
- response.go
- response.pb.go
- response.proto
- roundtrip.go
- roundtrip_test.go
- shard_query.go
- split_by_interval.go
- split_by_interval_test.go
- querysharding
- receive
- reloader
- replicate
- rules
- runutil
- server
- shipper
-
store
- cache
- hintspb
- labelpb
- storepb
- 6545postingsrepro
- acceptance_test.go
- bucket.go
- bucket_e2e_test.go
- bucket_test.go
- flushable.go
- io.go
- io_test.go
- lazy_postings.go
- lazy_postings_test.go
- limiter.go
- limiter_test.go
- local.go
- opts.go
- opts_test.go
- postings.go
- postings_codec.go
- postings_codec_test.go
- prometheus.go
- prometheus_test.go
- proxy.go
- proxy_heap.go
- proxy_heap_test.go
- proxy_test.go
- recover.go
- recover_test.go
- telemetry.go
- tsdb.go
- tsdb_test.go
- strutil
- targets
- tenancy
- testutil
- tls
- tracing
-
ui
-
react-app
- public
-
src
- components
- contexts
- fonts
- hooks
-
pages
- alerts
- config
- flags
-
graph
- CMTheme.tsx
- ColorPool.ts
- DataTable.test.tsx
- DataTable.tsx
- ExpressionInput.test.tsx
- ExpressionInput.tsx
- Graph.test.tsx
- Graph.tsx
- GraphControls.test.tsx
- GraphControls.tsx
- GraphHelpers.test.ts
- GraphHelpers.ts
- GraphTabContent.test.tsx
- GraphTabContent.tsx
- Legend.tsx
- Panel.test.tsx
- Panel.tsx
- PanelList.test.tsx
- PanelList.tsx
- QueryStatsView.test.tsx
- QueryStatsView.tsx
- SeriesName.test.tsx
- SeriesName.tsx
- TimeInput.test.tsx
- TimeInput.tsx
- rules
- serviceDiscovery
- status
-
targets
- __snapshots__
- __testdata__
- EndpointLink.test.tsx
- EndpointLink.tsx
- Filter.test.tsx
- Filter.tsx
- ScrapePoolContent.tsx
- ScrapePoolList.test.tsx
- ScrapePoolList.tsx
- ScrapePoolPanel.module.css
- TargetLabels.module.css
- TargetLabels.test.tsx
- TargetLabels.tsx
- Targets.test.tsx
- Targets.tsx
- target.test.ts
- target.ts
- tsdbStatus
- index.ts
- thanos
- themes
- types
- utils
- vendor
- App.css
- App.test.tsx
- App.tsx
- Theme.tsx
- globals.ts
- index.tsx
- react-app-env.d.ts
- setupTests.ts
- .eslintrc.json
- .gitignore
- README.md
- globals.d.ts
- package-lock.json
- package.json
- tsconfig.json
- static
- README.md
- bucket.go
- query.go
- rule.go
- ui.go
- ui_test.go
-
react-app
- verifier
- scripts
-
test
-
e2e
- e2ethanos
- compact_test.go
- compatibility_test.go
- distributed_query_test.go
- exemplars_api_test.go
- info_api_test.go
- metadata_api_test.go
- native_histograms_test.go
- query_frontend_test.go
- query_test.go
- receive_test.go
- rule_test.go
- rules_api_test.go
- store_gateway_test.go
- targets_api_test.go
- tls_test.go
- tools_bucket_web_test.go
- tracing_test.go
- travis-gcs-creds.json.enc
-
e2e
- tutorials
-
website
- archetypes
- data
- layouts
-
static
-
logos
- Adform_logo_RGB.png
- Adobe_logo.png
- OYO.png
- adfinis.png
- aivenlogo.png
- amadeus.png
- arlo.png
- authzed.png
- banzaicloud.png
- bb.png
- blablacar.png
- blinkit.png
- bytedance.png
- cartradetech.png
- civo.png
- cloudandheat.png
- darwinbox.png
- de-cix.png
- deno.png
- devolksbank.png
- ebay.png
- epidemicsound.png
- flatzone.png
- free-now.png
- fullstaq.png
- gmasmovil.png
- grupo-olx.png
- hetzner.png
- hotstar.jpg
- hyperia.png
- improbable.png
- infdevlogo.png
- itau-unibanco.png
- jetstack.png
- joblift.png
- jurumanisolutions.png
- kakaopay.png
- kollective.png
- lablabs.png
- leboncoin.png
- mallgroup.png
- meltwater.png
- mobiuspace.png
- monzo.png
- nos.png
- open-systems.png
- ozon.png
- p7s1.png
- pagbank.png
- qonto.png
- saucelabs.png
- scmp.png
- seznam.png
- softonic.png
- soundcloud.png
- stackhero.png
- sumup.png
- talend.png
- tangentsolutions.png
- tencent.png
- thebeat.png
- tidbcloud.png
- tiket.png
- tixngo.png
- toss.png
- truelayer.png
- truphone.png
- ubio.png
- udaan.png
- untab.png
- uswitch.png
- utilitywarehouse.png
- vestiairecollective.png
- vexxhost.png
- wehkamp.png
- wise.png
- workfront.png
- wwt.png
- xing.png
- zenduty.png
- CNAME
- Thanos-logo_full.svg
- cloud-native-computing.svg
- cloudraft.png
- expand.svg
- icon-dark.png
- icon-light.png
- main.css
- o11y.svg
- syntax.css
- tasrie-it-services.png
- thanos-og-image.png
-
logos
- .hugo_build.lock
- hugo.yaml
- .busybox-versions
- .cortex-packages.txt
- .dockerignore
- .errcheck_excludes.txt
- .gitattributes
- .gitignore
- .gitpod.yml
- .go-version
- .golangci.yml
- .mdox.prev-release.yaml
- .mdox.validate.yaml
- .mdox.yaml
- .promu.yml
- CHANGELOG.md
- CODE_OF_CONDUCT.md
- CONTRIBUTING.md
- Dockerfile
- Dockerfile.e2e-tests
- Dockerfile.multi-arch
- Dockerfile.multi-stage
- LICENSE
- MAINTAINERS.md
- Makefile
- README.md
- SECURITY.md
- VERSION
- doc.go
- go.mod
- go.sum
- netlify.toml
Explanation
The code defines a Rule
struct responsible for handling rule-related UI elements in a Thanos application. It leverages the BaseUI
struct, which likely provides basic UI functionalities and components.
Breakdown:
Rule
Struct:Holds a reference to a
BaseUI
instance for common UI operations.externalPrefix
andprefixHeader
are likely used for routing and header manipulation.ruleManager
points to athanosrules.Manager
instance for managing rules and alerts.queryURL
stores the base URL for querying metrics.reg
is a Prometheus registerer for metrics registration.NewRuleUI
Constructor:Initializes a
Rule
instance with provided logger, Prometheus registerer, rule manager, query URL, and routing prefixes.Defines template variables specific to the rules UI (e.g.,
Component
,queryURL
).Creates a template function map (
ruleTmplFuncs
) for handling specific UI tasks.Sets up the
BaseUI
with the provided configuration and component type.ruleTmplFuncs
Function:Provides a set of template functions used for formatting and manipulating data within UI templates:
since
: Calculates the time difference between a given timestamp and the current time.alertStateToClass
: Maps an alert state (e.g.,StateInactive
,StateFiring
) to a corresponding CSS class (e.g., “success”, “danger”).ruleHealthToClass
: Maps a rule health status (e.g.,HealthGood
,HealthUnknown
) to a CSS class.queryURL
: Returns the provided query URL.reReplaceAll
: Performs regular expression replacement in a string.humanizeDuration
: Formats a duration value in a human-readable format.Register
Method:Registers the rule UI under the given router
r
with instrumentation middlewareins
.Calls
registerReactApp
(not defined here, likely responsible for setting up a React-based application), passing the router, instrumentation, and theBaseUI
instance.
Key Points:
- This code implements the rule UI component within a Thanos application, relying on Prometheus rule management and UI functionalities provided by
BaseUI
. - It leverages template functions for formatting data, mapping alert states and rule health to CSS classes, and displaying durations in a user-friendly manner.
- The
Register
method integrates the rule UI into the application’s routing system, potentially utilizing a React framework for the frontend.
Graph
The graph shows the usage of functions within the codebase.
Select a code symbol to view it's graph