Skip to content

Commit 9d4b003

Browse files
authored
Merge pull request #3 from flant/link2kibana
Добавил ссылку на отдельную кибану
2 parents b572536 + e8a8538 commit 9d4b003

File tree

5 files changed

+18
-5
lines changed

5 files changed

+18
-5
lines changed

examples/main.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ app:
22
port: 9400
33
bind: 0.0.0.0
44
timeout: 60
5+
kibana: http://kibana.host
56
elastic:
6-
host: http://elasticsearch:9200/
7+
host: https://localhost:9200/
78
# use this fields if elastic requires BA
8-
# username: elastic
9-
# password: elastic
9+
username: admin
10+
password: admin
1011
ssl: false
12+
insecure: true
1113
# Видим-ли в списке снапшотов системые (.kibana* / .opendistro* )
1214
# значение по умолчанию = false, то-есть не видим
1315
include_system: false

front/index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<head>
44
<title>Elasticsearch: restore snapshots</title>
55
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
6+
67
<link rel="stylesheet" href="/assets/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
78
<style>
89
body {
@@ -130,6 +131,8 @@ <h5 class="modal-title" id="exampleModalLabel">X-tract indices from snapshot</h5
130131

131132
<script>
132133

134+
var kibana_url = "{{.}}"
135+
133136
var getnodes = setInterval(NodeStatus, 5000);
134137
var getindices = setInterval(IndexList, 3000);
135138

@@ -187,7 +190,7 @@ <h5 class="modal-title" id="exampleModalLabel">X-tract indices from snapshot</h5
187190

188191
basket = '<svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-folder2-open ' + done + '" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M1 3.5A1.5 1.5 0 0 1 2.5 2h2.764c.958 0 1.76.56 2.311 1.184C7.985 3.648 8.48 4 9 4h4.5A1.5 1.5 0 0 1 15 5.5v.64c.57.265.94.876.856 1.546l-.64 5.124A2.5 2.5 0 0 1 12.733 15H3.266a2.5 2.5 0 0 1-2.481-2.19l-.64-5.124A1.5 1.5 0 0 1 1 6.14V3.5zM2 6h12v-.5a.5.5 0 0 0-.5-.5H9c-.964 0-1.71-.629-2.174-1.154C6.374 3.334 5.82 3 5.264 3H2.5a.5.5 0 0 0-.5.5V6zm-.367 1a.5.5 0 0 0-.496.562l.64 5.124A1.5 1.5 0 0 0 3.266 14h9.468a1.5 1.5 0 0 0 1.489-1.314l.64-5.124A.5.5 0 0 0 14.367 7H1.633z"/></svg>';
189192

190-
str += "<li>"+ basket + "&nbsp;" + k + "<span class='float-right'>" + bytesToSize(ts) + "&nbsp;&nbsp;" + del_button+ "</span>";
193+
str += "<li><a href='" + kibana_url + "' target=_blank>" + basket + "</a>&nbsp;" + k + "<span class='float-right'>" + bytesToSize(ts) + "&nbsp;&nbsp;" + del_button+ "</span>";
191194
str += "<div class='progress' style='height: 3px;'>";
192195
str += "<div class='progress-bar " + pc + "' role='progressbar' style='width: " + prc + "%;' aria-valuenow='" + prc + "' aria-valuemin='0' aria-valuemax='100'></div>";
193196
str += "</div><br></li>";

modules/config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type Config struct {
2424
App struct {
2525
Port string `yaml:"port"`
2626
Bind string `yaml:"bind"`
27+
Kibana string `yaml:"kibana"`
2728
TimeOut int `yaml:"-"`
2829
TimeOutRaw *int `yaml:"timeout"`
2930
} `yaml:"app"`

modules/router/router.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"regexp"
2424
"sort"
2525
"strings"
26+
"text/template"
2627

2728
"time"
2829

@@ -147,7 +148,12 @@ func (rt *Router) FrontHandler(w http.ResponseWriter, r *http.Request) {
147148
w.Header().Set("Content-Type", contentType)
148149
w.Header().Set("Access-Control-Allow-Origin", "*")
149150
w.Header().Set("X-Server", version.Version)
150-
w.Write(data)
151+
if strings.Contains(file, ".html") {
152+
t := template.Must(template.New("index").Parse(string(data)))
153+
t.Execute(w, rt.conf.App.Kibana)
154+
} else {
155+
w.Write(data)
156+
}
151157
}
152158

153159
func (rt *Router) ApiHandler(w http.ResponseWriter, r *http.Request) {

modules/router/tls.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ func createTLSConfig(pemFile, pemCertFile, pemPrivateKeyFile string, insecureSki
4242
}
4343
tlsConfig.Certificates = []tls.Certificate{certs}
4444
}
45+
4546
return &tlsConfig
4647
}
4748

0 commit comments

Comments
 (0)