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

Log distributed queries results locally #30

Merged
merged 1 commit into from
Nov 5, 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
6 changes: 6 additions & 0 deletions cmd/admin/handlers-get.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,13 +547,19 @@ func queryLogsHandler(w http.ResponseWriter, r *http.Request) {
log.Printf("error getting targets %v", err)
return
}
defLink, dbLink := queryResultLink(query.Name)
resLink := ""
if defLink != dbLink {
resLink = dbLink
}
// Prepare template data
templateData := QueryLogsTemplateData{
Title: "Query logs " + query.Name,
Metadata: templateMetadata(ctx, serviceName, serviceVersion),
Environments: envAll,
Platforms: platforms,
Query: query,
ResultsLink: resLink,
QueryTargets: targets,
}
if err := t.Execute(w, templateData); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/admin/json-queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func jsonQueryHandler(w http.ResponseWriter, r *http.Request) {
data := make(QueryData)
data["query"] = q.Query
data["name"] = q.Name
data["link"] = queryResultLink(q.Name)
data["deflink"], data["dblink"] = queryResultLink(q.Name)
// Preparing query targets
ts, _ := queriesmgr.GetTargets(q.Name)
_ts := []QueryTarget{}
Expand Down
5 changes: 5 additions & 0 deletions cmd/admin/static/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,8 @@ button {
align-items: center;
justify-content: center;
}

.query-link {
font-family: monospace;
font-size: 1.3em;
}
8 changes: 8 additions & 0 deletions cmd/admin/static/js/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,11 @@ function confirmDeleteQueries(_names) {
});
$("#confirmModal").modal();
}

function queryResultLink(defLink, dbLink, query) {
var query_link = '<span class="query-link"><a href="' + defLink + '">' + query + '</a></span>';
if (defLink !== dbLink) {
query_link = '<span class="query-link"><a href="' + defLink + '">' + query + '</a></span> <a href="' + dbLink + '" _target="_blank"><i class="fas fa-external-link-alt"></i></a>';
}
return query_link
}
4 changes: 4 additions & 0 deletions cmd/admin/templates/queries-logs.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

<div class="animated fadeIn">

{{ $template := . }}
{{ with .Query }}
<div class="card mt-2">
<div class="card-header">
Expand All @@ -27,6 +28,9 @@
{{ else }}
<i class="fas fa-hourglass-half"></i> [ <b>ACTIVE</b> ] - Results for {{ .Name }}
{{ end }}
{{ if $template.ResultsLink }}
- <a href="{{ $template.ResultsLink }}" _target="_blank"><i class="fas fa-external-link-alt"></i></a>
{{ end }}
<div class="card-header-actions">
<button class="btn btn-sm btn-outline-primary" data-tooltip="true"
data-placement="bottom" title="Refresh table" onclick="refreshTableNow('tableQueryLogs');">
Expand Down
2 changes: 1 addition & 1 deletion cmd/admin/templates/queries.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
data: 'query',
render: function (data, type, row, meta) {
if (type === 'display') {
return '<span style="font-family: monospace; font-size: 1.3em;"><a href="'+data.link+'">'+data.query+'</a></span>';
return queryResultLink(data.deflink, data.dblink, data.query);
} else {
return data;
}
Expand Down
1 change: 1 addition & 0 deletions cmd/admin/types-templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ type QueryLogsTemplateData struct {
Environments []environments.TLSEnvironment
Platforms []string
Query queries.DistributedQuery
ResultsLink string
QueryTargets []queries.DistributedQueryTarget
Metadata TemplateMetadata
}
Expand Down
6 changes: 4 additions & 2 deletions cmd/admin/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,10 @@ func removeBackslash(rawString string) string {
}

// Helper to generate a link to results for on-demand queries
func queryResultLink(name string) string {
return strings.Replace(settingsmgr.QueryResultLink(), "{{NAME}}", removeBackslash(name), 1)
func queryResultLink(name string) (string, string) {
defaultLink := strings.Replace(settings.QueryLink, "{{NAME}}", removeBackslash(name), 1)
dbLink := strings.Replace(settingsmgr.QueryResultLink(), "{{NAME}}", removeBackslash(name), 1)
return defaultLink, dbLink
}

// Helper to generate a link to results for status logs
Expand Down
8 changes: 0 additions & 8 deletions plugins/db_logging/go.mod

This file was deleted.

144 changes: 0 additions & 144 deletions plugins/db_logging/go.sum

This file was deleted.

5 changes: 0 additions & 5 deletions plugins/graylog_logging/go.mod

This file was deleted.

2 changes: 0 additions & 2 deletions plugins/graylog_logging/go.sum

This file was deleted.

10 changes: 0 additions & 10 deletions plugins/logging_dispatcher/go.mod

This file was deleted.

Loading