promtail: restore ability to show target labels in promtail UI

PR #791 accidentally removed the ability to use the promtail UI
by removing methods from the Target interface that were only
used within the HTML templates.

Along with restoring the methods in the Target interface, this
commit also introduces details for the JournalTarget, which
currently only provides the position in the journal being
tracked.
pull/805/head
Robert Fratto 6 years ago committed by Robert Fratto
parent 24f5706a9a
commit f2bec3b0a5
  1. 4
      pkg/promtail/server/server.go
  2. 4
      pkg/promtail/server/ui/assets_vfsdata.go
  3. 21
      pkg/promtail/server/ui/templates/targets.html
  4. 10
      pkg/promtail/targets/filetarget.go
  5. 19
      pkg/promtail/targets/journaltarget.go
  6. 14
      pkg/promtail/targets/target.go

@ -149,6 +149,10 @@ func (s *Server) targets(rw http.ResponseWriter, _ *http.Request) {
// you can't cast with a text template in go so this is a helper
return details.(map[string]int64)
},
"journalTargetDetails": func(details interface{}) map[string]string {
// you can't cast with a text template in go so this is a helper
return details.(map[string]string)
},
"numReady": func(ts []targets.Target) (readies int) {
for _, t := range ts {
if t.Ready() {

@ -465,9 +465,9 @@ var Assets = func() http.FileSystem {
"/templates/targets.html": &vfsgen۰CompressedFileInfo{
name: "targets.html",
modTime: time.Date(1970, 1, 1, 0, 0, 1, 0, time.UTC),
uncompressedSize: 3098,
uncompressedSize: 3718,
compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xb4\x56\xcd\x8e\xdb\x36\x10\xbe\xfb\x29\x06\xac\x51\xb4\x40\xbc\x42\x72\x4c\x65\x15\x2d\x82\x9e\x7a\x08\x8a\xb4\xd7\x80\x12\x47\x16\x77\x69\x52\x21\x47\x6e\x0c\x96\xef\x5e\x90\x94\x6c\x59\x96\x17\x08\x8a\xfa\x60\x90\x9c\x99\x6f\xfe\x3e\x0e\xe5\xbd\xc0\x56\x6a\x04\xd6\x21\x17\x2c\x84\x4d\xa9\xa4\x7e\x01\x3a\xf7\xb8\x67\x84\x5f\xa9\x68\x9c\x63\x60\x51\xed\x99\xa3\xb3\x42\xd7\x21\x12\x83\xce\x62\xbb\x67\xde\x43\xcf\xa9\xfb\x68\xb1\x95\x5f\x21\x84\xc2\x11\x27\xd9\x44\x9b\x82\xb8\x3d\x20\xb9\xa7\xc6\xb9\x9f\x4f\x7b\xef\xa1\x1e\xa4\x12\x7f\xa1\x75\xd2\x68\x08\x81\x55\x9b\xd2\x35\x56\xf6\x04\xce\x36\x8f\xb1\x9e\xaf\x50\xcf\x8f\x90\xca\x22\x23\x55\x1b\xef\x51\x8b\x10\x36\x9b\xcd\x35\xb5\xc6\x68\x42\x4d\x31\x3b\x80\x52\xc8\x13\x34\x8a\x3b\xb7\x4f\x02\x2e\x35\xda\x5d\xab\x06\x29\x58\xb5\x01\x00\x28\xbb\xb7\xd5\xa7\xec\xb1\x2c\xba\xb7\xe3\x61\x34\x93\x62\xcf\x5c\x67\xfe\x1e\xa5\x6c\xc2\xa9\x49\xef\x0e\xd6\x0c\x3d\x5c\x56\x3b\x32\x87\x83\x42\x06\x82\x13\x1f\x37\x7b\x56\x0f\x44\x46\xbb\xd1\x11\x40\xa9\x78\x8d\x6a\x06\x93\x00\x7a\x2b\x8f\xdc\x9e\x2f\x5a\x00\xa5\xd4\xfd\x40\x63\x57\x2c\x17\xd2\x30\xd0\xfc\x18\x5b\x34\x85\x12\x63\xe3\x4a\xed\x2e\x07\x7c\x20\xd3\x98\x63\xaf\x90\x70\xcf\x4c\xdb\x32\x68\x3a\x6c\x5e\x50\x54\xf0\x8b\x52\x53\x04\x45\x0a\xe1\x7f\x0a\x68\xd0\x16\xb9\x38\xbf\x16\x54\x05\x7f\x66\xa5\x07\x01\x15\xb5\x8d\xeb\xb2\x10\xf2\x54\x6d\xd2\xa9\xf7\x96\xeb\x03\xc2\xf6\xd9\xd4\x6f\x60\xdb\x1b\xa3\xe0\xfd\x1e\x9e\x72\x5b\x3e\x1a\xa3\x5c\x6a\x75\xd4\xdc\x26\xec\x28\xd6\xc3\xf1\x8f\xb4\x4e\x06\x57\x05\x32\xc4\x93\xbd\x42\x7d\x91\x5d\x7b\x3e\x96\x82\x78\xad\x70\x77\x21\xcc\xb5\x83\xdd\xbb\x49\xe5\xd9\xd4\x9f\xe3\x2d\x42\xeb\xbd\x6c\x41\x11\x8c\xce\xb3\x8b\x10\x40\xc4\xb0\xed\x48\xd1\x79\x35\x79\xaa\xd6\xb3\xa9\x77\xde\xc7\xac\x42\x98\x6e\xd8\x77\x37\x87\xd5\xb4\x82\x1f\xa6\xd4\x42\x28\xa6\x24\x42\x80\x74\xf4\x63\x59\xf0\x19\x78\x26\xdd\xd8\xab\xbc\x61\xd7\xb4\x52\x63\x00\xbf\xf6\x5c\x0b\x14\xbb\x94\x27\xdc\x35\x3e\xb2\x1e\x14\x3a\x57\x16\x19\xe1\xda\x9f\xee\xdd\x65\x9d\x8d\xe7\x15\x83\x5c\x37\x77\x1c\x17\xb5\xb1\x02\x2d\x8a\xe9\x9c\xac\xec\x2f\xbb\xce\x9c\x66\x95\x8d\x78\xb1\x9c\xf3\xf2\x0a\x24\x2e\x95\x9b\xe9\x44\x2d\x3b\xdf\x26\xb3\xea\xd3\xb9\xc7\xb2\xa0\xee\x5e\x92\x38\xb0\x2e\xfa\x3d\x12\xcf\xad\xcb\x3e\x64\xcf\x4b\x61\x59\xcc\xbd\x47\x29\x72\x31\xcf\xa0\x36\xe2\x7c\xdd\x5f\x98\x3b\xa3\xe0\xc3\x2c\x2e\x99\xc7\xce\xb1\x5b\x29\x40\xe9\x7a\xae\xa1\xf2\xfe\x29\xe6\x1a\x42\xec\x79\x59\x2f\x41\x0a\x12\x0f\x61\xe3\x7c\x7d\x84\x3b\xaa\x70\x85\x96\x20\xfd\xef\xbc\x07\xd9\xc2\x53\xbe\x43\x21\xb8\xa1\x69\xd0\x39\xef\x51\x39\x0c\xe1\x86\xda\x90\xa0\x3f\x4b\x2d\x64\xc3\xc9\x58\x88\x0f\xc9\x6e\xe8\x7b\xb4\x0d\x77\xf7\x3e\x63\x61\x32\xf0\x4d\x4d\x72\x06\x31\x9e\x6f\xc8\x2a\x4d\x0f\xf7\x7a\x5a\xcd\x60\x9d\xb1\xbb\xde\x48\x4d\x68\x17\x33\x9a\x8c\x51\x24\x7b\x06\x24\x29\xee\x47\x71\x47\x47\xb5\x27\x3b\x60\xde\x1a\x2b\x0f\x52\x73\xb5\x1b\xb5\xca\xba\xfa\x15\x5b\x63\x31\x3e\x95\x31\x04\xa9\x0f\xef\xcb\xa2\xae\x2e\x2d\x7f\x79\x03\xdb\x53\x9a\x53\x1f\xa4\x6b\x22\xd5\x51\x64\xc6\x85\x10\x1b\xe7\xfd\x16\x93\x7c\x7b\x82\x7f\x20\xba\x0b\xc1\xfb\xed\x4b\x08\xfb\xef\xbf\x0c\x86\x7e\x4a\x0a\x21\x4c\x9b\xe5\x10\xb9\xe3\x58\x0a\x23\x3a\xe5\x6a\xc0\xe4\x78\x72\x77\x67\xb3\xa8\x4f\xcd\xc5\x01\x21\xfd\x5f\x47\x80\xf7\x19\x31\x84\xf8\x56\x67\xd4\x10\xd8\x5a\x83\x72\x18\x99\x18\xf0\x2d\xce\x04\xb6\x7c\x50\xc4\x2a\x6d\x34\xbe\x82\x9c\x9e\xf8\xff\x48\x94\xb5\x59\x92\xe1\x65\x0b\xf8\x05\xd2\xbd\x02\xf6\x9b\x54\xc8\xee\xbc\xad\x04\xb5\x6d\xa5\x42\x17\xeb\x1c\x17\xf9\x2d\x1a\xa7\x06\x3c\x8d\x8b\x95\xd2\xaf\x0c\xcd\x95\xa6\xc2\x65\x1c\xae\xcb\x56\x06\xc8\xc2\x14\x5c\x63\xe2\x03\xd0\x18\xc5\xaa\x8f\x9c\xba\xfb\x39\xf7\xaa\x85\x71\x92\xa4\xd1\xaf\x59\xdd\x0e\xc3\x85\xe4\x51\xec\xcb\x11\x39\xfd\xae\xa3\x92\x53\x97\x5e\xf9\x1c\x40\xba\x21\xa9\xd4\xeb\x3c\x7e\x18\x02\x89\x48\xe1\x88\x16\x87\xe5\x92\x18\x4b\xb5\xd1\xdb\x63\xd5\xf5\x64\xd7\xb9\x99\xb4\xd7\xd2\x2c\x8b\xd4\xf0\x7b\x0a\xde\xa3\x2c\xe3\xb8\xf5\xbf\xb4\x58\xf8\xbb\xf1\x33\x7e\x4a\x65\x33\x40\x2d\x20\x7f\x18\xe7\xe3\x09\xe9\xdf\x00\x00\x00\xff\xff\x82\x0b\x48\x9c\x1a\x0c\x00\x00"),
compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x56\x4f\xcf\xe3\x34\x13\xbf\xf7\x53\x8c\xfc\x56\xaf\x40\xda\x3e\xd1\xee\x71\x49\x82\x40\x2b\x0e\xc0\x61\x85\x96\xbd\xae\x9c\x78\xd2\xb8\x8f\x6b\x67\x6d\xa7\x3c\x95\xf1\x77\x47\xb6\x93\x34\x4d\xd3\xa2\x15\x20\x71\xa0\x87\xc8\xf6\xcc\xfc\xe6\xdf\xcf\xe3\x3a\xc7\xb0\xe1\x12\x81\xb4\x48\x19\xf1\x7e\x93\x0b\x2e\x9f\xc1\x9e\x3b\x2c\x88\xc5\x17\x9b\xd5\xc6\x10\xd0\x28\x0a\x62\xec\x59\xa0\x69\x11\x2d\x81\x56\x63\x53\x10\xe7\xa0\xa3\xb6\x7d\xaf\xb1\xe1\x2f\xe0\x7d\x66\x2c\xb5\xbc\x0e\x36\x99\xa5\x7a\x8f\xd6\x3c\xd5\xc6\x7c\x7b\x2a\x9c\x83\xaa\xe7\x82\x7d\x44\x6d\xb8\x92\xe0\x3d\x29\x37\xb9\xa9\x35\xef\x2c\x18\x5d\xdf\xc7\x3a\x5c\xa0\x0e\xf7\x90\xf2\x2c\x21\x95\x1b\xe7\x50\x32\xef\x37\x9b\xcd\x25\xb5\x5a\x49\x8b\xd2\x86\xec\x00\x72\xc6\x4f\x50\x0b\x6a\x4c\x11\x05\x94\x4b\xd4\xbb\x46\xf4\x9c\x91\x72\x03\x00\x90\xb7\xaf\xcb\x0f\xc9\x63\x9e\xb5\xaf\x87\xc3\x60\xc6\x59\x41\x4c\xab\x7e\x1b\xa4\x64\xc4\xa9\xac\xdc\xed\xb5\xea\x3b\x98\x56\x3b\xab\xf6\x7b\x81\x04\x18\xb5\x74\xd8\x14\xa4\xea\xad\x55\xd2\x0c\x8e\x00\x72\x41\x2b\x14\x33\x98\x08\xd0\x69\x7e\xa4\xfa\x3c\x69\x01\xe4\x5c\x76\xbd\x1d\xba\xa2\x29\xe3\x8a\x80\xa4\xc7\xd0\xa2\x31\x94\x10\x1b\x15\x62\x37\x1d\xd0\xde\xaa\x5a\x1d\x3b\x81\x16\x0b\xa2\x9a\x86\x40\xdd\x62\xfd\x8c\xac\x84\xef\x84\x18\x23\xc8\x62\x08\xff\x50\x40\xbd\xd4\x48\xd9\xf9\x51\x50\x25\xfc\x9a\x94\xee\x04\x94\x55\x3a\xac\xf3\x8c\xf1\x53\xb9\x89\xa7\xce\x69\x2a\xf7\x08\xdb\x83\xaa\x5e\xc1\xb6\x53\x4a\xc0\xdb\x02\x9e\x52\x5b\xde\x2b\x25\x4c\x6c\x75\xd0\xdc\x46\xec\x20\x96\xfd\xf1\x97\xb8\x8e\x06\x17\x05\xab\x2c\x8d\xf6\x02\xe5\x24\xbb\xf4\x7c\x28\x85\xa5\x95\xc0\xdd\x44\x98\x4b\x07\xdb\x37\xa3\xca\x41\x55\x9f\xc2\x2d\x42\xed\x1c\x6f\x40\x58\x18\x9c\x27\x17\xde\x03\x0b\x61\xeb\x81\xa2\xf3\x6a\xd2\x58\xad\x83\xaa\x76\xce\x85\xac\xbc\x1f\x6f\xd8\xff\xae\x0e\xcb\x71\x05\x5f\x8d\xa9\x79\x9f\x8d\x49\x78\x0f\xf1\xe8\xeb\x3c\xa3\x33\xf0\x44\xba\xa1\x57\x69\x43\x2e\x69\xc5\xc6\x00\xbe\x74\x54\x32\x64\xbb\x98\x27\xdc\x34\x3e\xb0\x1e\x04\x1a\x93\x67\x09\xe1\xd2\x9f\xf6\xcd\xb4\x4e\xc6\xf3\x8a\x41\xaa\x9b\x39\x0e\x8b\x4a\x69\x86\x1a\xd9\x78\x6e\x35\xef\xa6\x5d\xab\x4e\xb3\xca\x06\xbc\x50\xce\x79\x79\x19\x5a\xca\x85\x99\xe9\x04\x2d\x3d\xdf\x46\xb3\xf2\xc3\xb9\xc3\x3c\xb3\xed\xad\x24\x72\x60\x5d\xf4\x73\x20\x9e\x59\x97\xbd\x4b\x9e\x97\xc2\x3c\x9b\x7b\x0f\x52\xa4\x6c\x9e\x41\xa5\xd8\xf9\xb2\x9f\x98\x3b\xa3\xe0\xdd\x2c\xa6\xcc\x43\xe7\xc8\xb5\x14\x20\x37\x1d\x95\x50\x3a\xf7\x14\x72\xf5\x3e\xf4\x3c\xaf\x96\x20\x99\x65\x77\x61\xc3\x7c\xbd\x87\x3b\xa8\x50\x81\xda\x42\xfc\xee\x9c\x03\xde\xc0\x53\xba\x43\xde\x9b\xbe\xae\xd1\x18\xe7\x50\x18\xf4\xfe\x8a\xda\x10\xa1\x3f\x71\xc9\x78\x4d\xad\xd2\x10\x1e\x92\x5d\xdf\x75\xa8\x6b\x6a\x6e\x7d\x86\xc2\x24\xe0\xab\x9a\xa4\x0c\x42\x3c\x5f\x90\x55\x9c\x1e\xe6\x71\x5a\x75\xaf\x8d\xd2\xbb\x4e\x71\x69\x51\x2f\x66\xb4\x55\x4a\x58\xde\x11\xb0\xdc\x86\xfd\x20\x6e\xed\x51\x14\x56\xf7\x98\xb6\x4a\xf3\x3d\x97\x54\xec\x06\xad\xbc\x2a\xbf\xc7\x46\x69\x0c\x4f\x65\x08\x81\xcb\xfd\xdb\x3c\xab\xca\xa9\xe5\xcf\xaf\x60\x7b\x8a\x73\xea\x1d\x37\x75\xa0\x3a\xb2\xc4\x38\xef\x43\xe3\x9c\xdb\x62\x94\x6f\x4f\xf0\x3b\x04\x77\xde\x3b\xb7\x7d\xf6\xbe\xf8\xff\xe7\x5e\xd9\x6f\xa2\x82\xf7\xe3\x66\x39\x44\x6e\x38\x16\xc3\x08\x4e\xa9\xe8\x31\x3a\x1e\xdd\xdd\xd8\x2c\xea\x53\x51\xb6\x47\x88\xdf\xcb\x08\x70\x2e\x21\x7a\x1f\xde\xea\x84\xea\x3d\x59\x6b\x50\x0a\x23\x11\xe3\x4b\x7c\x31\x6c\x68\x2f\x2c\x29\xa5\x92\xf8\x00\x38\xbe\xf0\x7f\x91\x27\x6b\xa3\x24\xc1\xf3\x06\xf0\x33\xc4\x6b\x05\xe4\x07\x2e\x90\xac\x64\xe1\xdc\xb6\xe1\x02\x4d\xa8\x6b\x58\xa4\xb7\x67\x98\x12\xf0\x34\x2c\x56\x0c\x57\x86\xe4\x4a\x13\x61\x1a\x7f\xeb\xb2\x95\x81\xb1\x30\x05\x53\xab\x30\xf0\x6b\x25\x48\xf9\x9e\xda\xf6\x76\xae\x3d\xb4\x50\x86\x5b\xae\xe4\x23\xab\xeb\xe1\xb7\x90\xdc\x8b\x7d\x39\x12\xc7\xdf\x65\x34\x52\xdb\xc6\x57\x3d\x05\x10\x6f\x44\x2c\xf5\x3a\x97\xee\x86\x60\x59\xa0\x6c\x40\x0b\xc3\x71\xc9\x84\xa5\xda\xe0\xed\xbe\xea\x7a\xb2\xeb\x64\x8c\xda\x6b\x69\xe6\x59\x6c\xf8\x2d\xe7\xc2\x5d\x81\x2b\xe2\xfd\xa8\x7a\x2d\xa9\x20\xf0\x27\xe4\x3b\x24\xbd\x7f\x37\xff\x7e\xc2\x95\x27\xf7\x91\xc1\xc7\x30\x5d\xfe\xe3\xde\xc3\x64\xff\x36\xee\xdd\xa0\x2c\xe3\xb8\xf6\xbf\xb4\x58\xf8\xbb\xf2\x33\xfc\x6d\x4f\x66\x80\x92\x25\x3a\x0f\xc7\x23\xd2\x1f\x01\x00\x00\xff\xff\x1b\x27\x86\xef\x86\x0e\x00\x00"),
},
}
fs["/"].(*vfsgen۰DirInfo).entries = []os.FileInfo{

@ -50,14 +50,13 @@
<span class="cursor-pointer" data-toggle="tooltip" title="" data-html=true data-original-title="<b>Before relabeling:</b>{{range $k, $v := .DiscoveredLabels}}<br>{{$ev := $v | html}}{{$k}}=&quot;{{$ev}}&quot;{{end}}">
{{range $label, $value := .Labels}}
<span class="badge badge-primary">{{$label}}="{{$value}}"</span>
{{else}}
{{else}}
<span class="badge badge-default">none</span>
{{end}}
</span>
</td>
<td class="details">
{{if eq .Type "File"}}
{{$files := fileTargetDetails .Details}}
<table class="table">
<thead>
@ -75,6 +74,24 @@
{{end}}
</tbody>
</table>
{{else if eq .Type "Journal" }}
{{$files := journalTargetDetails .Details}}
<table class="table">
<thead>
<tr>
<th scope="col">Key</th>
<th scope="col">Value</th>
</tr>
</thead>
<tbody>
{{range $path, $position := $files}}
<tr>
<td>{{$path}}</td>
<td>{{$position}}</td>
</tr>
{{end}}
</tbody>
</table>
{{end}}
</td>
</tr>

@ -130,6 +130,16 @@ func (t *FileTarget) Type() TargetType {
return FileTargetType
}
// DiscoveredLabels implements a Target
func (t *FileTarget) DiscoveredLabels() model.LabelSet {
return t.discoveredLabels
}
// Labels implements a Target
func (t *FileTarget) Labels() model.LabelSet {
return t.labels
}
// Details implements a Target
func (t *FileTarget) Details() interface{} {
files := map[string]int64{}

@ -186,11 +186,26 @@ func (t *JournalTarget) Ready() bool {
return true
}
// Details returns target-specific details (currently nil).
func (t *JournalTarget) Details() interface{} {
// DiscoveredLabels returns the set of labels discovered by
// the JournalTarget, which is always nil. Implements
// Target.
func (t *JournalTarget) DiscoveredLabels() model.LabelSet {
return nil
}
// Labels returns the set of labels that statically apply to
// all log entries produced by the JournalTarget.
func (t *JournalTarget) Labels() model.LabelSet {
return t.labels
}
// Details returns target-specific details.
func (t *JournalTarget) Details() interface{} {
return map[string]string{
"position": t.positions.GetString(t.positionPath),
}
}
// Stop shuts down the JournalTarget.
func (t *JournalTarget) Stop() error {
t.until <- time.Now()

@ -22,6 +22,10 @@ const (
type Target interface {
// Type of the target
Type() TargetType
// DiscoveredLabels returns labels discovered before any relabeling.
DiscoveredLabels() model.LabelSet
// Labels returns labels that are added to this target and its stream.
Labels() model.LabelSet
// Ready tells if the targets is ready
Ready() bool
// Details is additional information about this target specific to its type
@ -51,6 +55,16 @@ func (d *droppedTarget) Type() TargetType {
return DroppedTargetType
}
// DiscoveredLabels implements Target
func (d *droppedTarget) DiscoveredLabels() model.LabelSet {
return d.discoveredLabels
}
// Labels implements Target
func (d *droppedTarget) Labels() model.LabelSet {
return nil
}
// Ready implements Target
func (d *droppedTarget) Ready() bool {
return false

Loading…
Cancel
Save