Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promtail targets page #532

Merged
merged 8 commits into from
May 6, 2019
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
36 changes: 36 additions & 0 deletions .gometalinter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"Vendor": true,
"Deadline": "5m",
"Concurrency": 2,
"Linters": {
"gofmt": {"Command": "gofmt -l -s -w"},
"goimports": {"Command": "goimports -l -w"}
},
"Exclude": [
"\\.pb\\.go",
"pkg/promtail/server/ui/assets_vfsdata.go",
"method Seek.*should have signature",
"error return value not checked \\(level\\.",
"\"err\" shadows declaration"
],

"Enable": [
"deadcode",
"errcheck",
"goconst",
"gofmt",
"goimports",
"golint",
"gosimple",
"gotypex",
"ineffassign",
"megacheck",
"misspell",
"structcheck",
"unconvert",
"unparam",
"varcheck",
"vet",
"vetshadow"
]
}
29 changes: 28 additions & 1 deletion Gopkg.lock

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

16 changes: 14 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all test clean images protos
.PHONY: all test clean images protos assets check_assets
.DEFAULT_GOAL := all

CHARTS := production/helm/loki production/helm/promtail production/helm/loki-stack
Expand Down Expand Up @@ -90,6 +90,7 @@ vendor/github.com/cortexproject/cortex/pkg/ingester/client/cortex.pb.go: vendor/
vendor/github.com/cortexproject/cortex/pkg/chunk/storage/caching_index_client.pb.go: vendor/github.com/cortexproject/cortex/pkg/chunk/storage/caching_index_client.proto
pkg/parser/labels.go: pkg/parser/labels.y
pkg/parser/matchers.go: pkg/parser/matchers.y
pkg/promtail/server/ui/assets_vfsdata.go: assets
all: $(UPTODATE_FILES)
test: $(PROTO_GOS) $(YACC_GOS)
debug: $(DEBUG_UPTODATE_FILES)
Expand Down Expand Up @@ -245,5 +246,16 @@ helm-publish: helm

clean:
$(SUDO) docker rmi $(IMAGE_NAMES) $(DEBUG_IMAGE_NAMES) >/dev/null 2>&1 || true
rm -rf $(UPTODATE_FILES) $(EXES) $(DEBUG_UPTODATE_FILES) $(DEBUG_EXES) $(DEBUG_DLV_FILES) .cache
rm -rf $(UPTODATE_FILES) $(EXES) $(DEBUG_UPTODATE_FILES) $(DEBUG_EXES) $(DEBUG_DLV_FILES) .cache pkg/promtail/server/ui/assets_vfsdata.go
go clean ./...

assets:
@echo ">> writing assets"
go generate -x -v ./pkg/promtail/server/ui

check_assets: assets
@echo ">> checking that assets are up-to-date"
@if ! (cd pkg/promtail/server/ui && git diff --exit-code); then \
echo "Run 'make assets' and commit the changes to fix the error."; \
exit 1; \
fi
2 changes: 1 addition & 1 deletion cmd/promtail/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func main() {
flagext.RegisterFlags(&config)
flag.Parse()

util.InitLogger(&config.ServerConfig)
util.InitLogger(&config.ServerConfig.Config)

if configFile != "" {
if err := helpers.LoadConfig(configFile, &config); err != nil {
Expand Down
12 changes: 12 additions & 0 deletions docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ to
target_label: __path__
```

## Troubleshooting targets

Promtail offers two pages that you can use to understand how service discovery works.
The service discovery page (`/service-discovery`) shows all discovered targets with their labels before and after relabeling as well as the reason why the target has been dropped.
The targets page (`/targets`) however displays only targets being actively scraped with their respective labels, files and positions.

You can access those two pages by port-forwarding the promtail port (9080 or 3101 via helm) locally:

```bash
kubectl port-forward loki-promtail-jrfg7 9080
```

## Debug output

Both binaries support a log level parameter on the command-line, e.g.: `loki —log.level= debug ...`
Expand Down
11 changes: 6 additions & 5 deletions pkg/logproto/logproto.pb.go

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

3 changes: 1 addition & 2 deletions pkg/promtail/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ package config
import (
"flag"

"github.com/weaveworks/common/server"

"github.com/grafana/loki/pkg/promtail/client"
"github.com/grafana/loki/pkg/promtail/positions"
"github.com/grafana/loki/pkg/promtail/scrape"
"github.com/grafana/loki/pkg/promtail/server"
"github.com/grafana/loki/pkg/promtail/targets"
)

Expand Down
14 changes: 2 additions & 12 deletions pkg/promtail/promtail.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package promtail

import (
"net/http"

"github.com/cortexproject/cortex/pkg/util"
"github.com/weaveworks/common/server"

"github.com/grafana/loki/pkg/promtail/client"
"github.com/grafana/loki/pkg/promtail/config"
"github.com/grafana/loki/pkg/promtail/positions"
"github.com/grafana/loki/pkg/promtail/server"
"github.com/grafana/loki/pkg/promtail/targets"
)

Expand Down Expand Up @@ -37,19 +35,11 @@ func New(cfg config.Config) (*Promtail, error) {
return nil, err
}

server, err := server.New(cfg.ServerConfig)
server, err := server.New(cfg.ServerConfig, tms)
if err != nil {
return nil, err
}

server.HTTP.Path("/ready").Handler(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
if tms.Ready() {
rw.WriteHeader(http.StatusNoContent)
} else {
rw.WriteHeader(http.StatusInternalServerError)
}
}))

return &Promtail{
client: client,
positions: positions,
Expand Down
Loading