Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
* [ENHANCEMENT] Add `gen index` and `gen bloom` commands to tempo-cli. [#903](https://github.com/grafana/tempo/pull/903) (@annanay25)
* [ENHANCEMENT] Implement trace comparison in Vulture [#904](https://github.com/grafana/tempo/pull/904) (@zalegrala)
* [ENHANCEMENT] Dedupe search records while replaying WAL [#940](https://github.com/grafana/tempo/pull/940) (@annanay25)
* [ENHANCEMENT] Add status endpoint to list the available endpoints [#938](https://github.com/grafana/tempo/pull/938) (@zalegrala)
* [CHANGE] Renamed CLI flag from `--storage.trace.maintenance-cycle` to `--storage.trace.blocklist_poll`. This is a **breaking change** [#897](https://github.com/grafana/tempo/pull/897) (@mritunjaysharma394)
* [CHANGE] update jsonnet alerts and recording rules to use `job_selectors` and `cluster_selectors` for configurable unique identifier labels [#935](https://github.com/grafana/tempo/pull/935) (@kevinschoonover)
* [CHANGE] Modify generated tag keys in Vulture for easier filtering [#934](https://github.com/grafana/tempo/pull/934) (@zalegrala)
Expand Down
75 changes: 75 additions & 0 deletions cmd/tempo/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"flag"
"fmt"
"io"
"net/http"
"sort"
"time"
Expand All @@ -16,8 +17,10 @@ import (
"github.com/cortexproject/cortex/pkg/util/grpc/healthcheck"
"github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/kit/log/level"
"github.com/gorilla/mux"
"github.com/grafana/dskit/modules"
"github.com/grafana/dskit/services"
"github.com/jedib0t/go-pretty/v6/table"
"github.com/weaveworks/common/middleware"
"github.com/weaveworks/common/server"
"github.com/weaveworks/common/signals"
Expand All @@ -38,6 +41,7 @@ import (
)

const metricsNamespace = "tempo"
const apiDocs = "https://grafana.com/docs/tempo/latest/api_docs/"

// Config is the root config for App.
type Config struct {
Expand Down Expand Up @@ -245,6 +249,7 @@ func (t *App) Run() error {
t.Server.HTTP.Path("/config").Handler(t.configHandler())
t.Server.HTTP.Path("/ready").Handler(t.readyHandler(sm))
t.Server.HTTP.Path("/services").Handler(t.servicesHandler())
t.Server.HTTP.Path("/status").Handler(t.statusHandler())
grpc_health_v1.RegisterHealthServer(t.Server.GRPC, healthcheck.New(sm))

// Let's listen for events from this manager, and log them.
Expand Down Expand Up @@ -341,6 +346,24 @@ func (t *App) readyHandler(sm *services.Manager) http.HandlerFunc {
}
}

func (t *App) statusHandler() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
msg := bytes.Buffer{}

v := r.URL.Query()
_, ok := r.URL.Query()["endpoints"]
if len(v) == 0 || ok {
t.writeStatusEndpoints(&msg)
}

w.Header().Set("Content-Type", "text/plain")
w.WriteHeader(http.StatusOK)
if _, err := w.Write(msg.Bytes()); err != nil {
level.Error(log.Logger).Log("msg", "error writing response", "err", err)
}
}
}

func (t *App) servicesHandler() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
msg := bytes.Buffer{}
Expand Down Expand Up @@ -368,3 +391,55 @@ func (t *App) servicesHandler() http.HandlerFunc {
}
}
}

func (t *App) writeStatusEndpoints(w io.Writer) {
type endpoint struct {
name string
regex string
}

endpoints := []endpoint{}

err := t.Server.HTTP.Walk(func(route *mux.Route, router *mux.Router, ancestors []*mux.Route) error {
e := endpoint{}

pathTemplate, err := route.GetPathTemplate()
if err == nil {
e.name = pathTemplate
}

pathRegexp, err := route.GetPathRegexp()
if err == nil {
e.regex = pathRegexp
}

endpoints = append(endpoints, e)

return nil
})
if err != nil {
level.Error(log.Logger).Log("msg", "error walking routes", "err", err)
}

sort.Slice(endpoints[:], func(i, j int) bool {
return endpoints[i].name < endpoints[j].name
})

x := table.NewWriter()
x.SetOutputMirror(w)
x.AppendHeader(table.Row{"name", "regex"})

for _, e := range endpoints {
x.AppendRows([]table.Row{
{e.name, e.regex},
})
}

x.AppendSeparator()
x.Render()

_, err = w.Write([]byte(fmt.Sprintf("\nAPI documentation: %s\n", apiDocs)))
if err != nil {
level.Error(log.Logger).Log("msg", "error writing response", "err", err)
}
}
11 changes: 11 additions & 0 deletions docs/tempo/website/api_docs/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ For the sake of clarity, in this document we have grouped API endpoints by servi
| [Distributor ring status](#distributor-ring-status) (*) | Distributor | HTTP | `GET /distributor/ring` |
| [Ingesters ring status](#ingesters-ring-status) | Distributor, Querier | HTTP | `GET /ingester/ring` |
| [Compactor ring status](#compactor-ring-status) | Compactor | HTTP | `GET /compactor/ring` |
| [Status](#status) | Status | HTTP | `GET /status` |

_(*) This endpoint is not always available, check the specific section for more details._

Expand Down Expand Up @@ -199,3 +200,13 @@ Displays a web page with the compactor hash ring status, including the state, he
compactor.

_For more information, check the page on [consistent hash ring](../operations/consistent_hash_ring)._

### Status

```
GET /status
```
Print all available information by default.

Comment thread
zalegrala marked this conversation as resolved.
Query Parameter:
- `endpoints`: Prints status information about the API endpoints.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ require (
github.com/hashicorp/go-hclog v0.14.0
github.com/hashicorp/go-plugin v1.3.0
github.com/jaegertracing/jaeger v1.21.0
github.com/jedib0t/go-pretty/v6 v6.2.4
github.com/jsternberg/zap-logfmt v1.2.0
github.com/klauspost/compress v1.13.1
github.com/minio/minio-go/v7 v7.0.10
Expand Down
7 changes: 6 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,7 @@ github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4
github.com/fsouza/fake-gcs-server v1.7.0 h1:Un0BXUXrRWYSmYyC1Rqm2e2WJfTPyDy/HGMz31emTi8=
github.com/fsouza/fake-gcs-server v1.7.0/go.mod h1:5XIRs4YvwNbNoz+1JF8j6KLAyDh7RHGAyAK3EP2EsNk=
github.com/fullsailor/pkcs7 v0.0.0-20190404230743-d7302db945fa/go.mod h1:KnogPXtdwXqoenmZCw6S+25EAm2MkxbG0deNDu4cbSA=
github.com/fzipp/gocyclo v0.3.1/go.mod h1:DJHO6AUmbdqj2ET4Z9iArSuwWgYDRryYt2wASxc7x3E=
github.com/garyburd/redigo v0.0.0-20150301180006-535138d7bcd7/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY=
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
github.com/gdamore/tcell v1.3.0/go.mod h1:Hjvr+Ofd+gLglo7RYKxxnzCBmev3BzsS67MebKS4zMM=
Expand Down Expand Up @@ -1186,6 +1187,8 @@ github.com/jcmturner/gokrb5/v8 v8.4.2 h1:6ZIM6b/JJN0X8UM43ZOM6Z4SJzla+a/u7scXFJz
github.com/jcmturner/gokrb5/v8 v8.4.2/go.mod h1:sb+Xq/fTY5yktf/VxLsE3wlfPqQjp0aWNYyvBVK62bc=
github.com/jcmturner/rpc/v2 v2.0.3 h1:7FXXj8Ti1IaVFpSAziCZWNzbNuZmnvw/i6CqLNdWfZY=
github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc=
github.com/jedib0t/go-pretty/v6 v6.2.4 h1:wdaj2KHD2W+mz8JgJ/Q6L/T5dB7kyqEFI16eLq7GEmk=
github.com/jedib0t/go-pretty/v6 v6.2.4/go.mod h1:+nE9fyyHGil+PuISTCrp7avEdo6bqoMwqZnuiK2r2a0=
github.com/jessevdk/go-flags v0.0.0-20180331124232-1c38ed7ad0cc/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc=
Expand Down Expand Up @@ -1333,8 +1336,9 @@ github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzp
github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.6/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.8 h1:3tS41NlGYSmhhe/8fhGRzc+z3AYCw1Fe1WAyLuujKs0=
github.com/mattn/go-runewidth v0.0.8/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-shellwords v1.0.3/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o=
github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/mattn/go-sqlite3 v1.11.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
Expand Down Expand Up @@ -2255,6 +2259,7 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180816055513-1c9583448a9c/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down
21 changes: 21 additions & 0 deletions vendor/github.com/jedib0t/go-pretty/v6/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading