Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Loki
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Loki
Commits
03dc4e63
Commit
03dc4e63
authored
5 years ago
by
Ed
Committed by
Cyril Tovena
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Parse the addr into a URL so we can extract the Host name for use in the TLSConfig (#778)
parent
f74f2c82
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cmd/logcli/client.go
+6
-4
6 additions, 4 deletions
cmd/logcli/client.go
cmd/logcli/main.go
+20
-9
20 additions, 9 deletions
cmd/logcli/main.go
with
26 additions
and
13 deletions
cmd/logcli/client.go
+
6
−
4
View file @
03dc4e63
...
...
@@ -54,7 +54,8 @@ func listLabelValues(name string) (*logproto.LabelResponse, error) {
}
func
doRequest
(
path
string
,
out
interface
{})
error
{
url
:=
*
addr
+
path
addrURL
.
Path
=
path
url
:=
addrURL
.
String
()
if
!*
quiet
{
log
.
Print
(
url
)
}
...
...
@@ -71,7 +72,7 @@ func doRequest(path string, out interface{}) error {
CAFile
:
*
tlsCACertPath
,
CertFile
:
*
tlsClientCertPath
,
KeyFile
:
*
tlsClientCertKeyPath
,
ServerName
:
url
,
ServerName
:
addrURL
.
Host
,
InsecureSkipVerify
:
*
tlsSkipVerify
,
},
}
...
...
@@ -110,14 +111,15 @@ func wsConnect(path string) (*websocket.Conn, error) {
CAFile
:
*
tlsCACertPath
,
CertFile
:
*
tlsClientCertPath
,
KeyFile
:
*
tlsClientCertKeyPath
,
ServerName
:
*
addr
,
ServerName
:
addr
URL
.
Host
,
InsecureSkipVerify
:
*
tlsSkipVerify
,
})
if
err
!=
nil
{
return
nil
,
err
}
url
:=
*
addr
+
path
addrURL
.
Path
=
path
url
:=
addrURL
.
String
()
if
strings
.
HasPrefix
(
url
,
"https"
)
{
url
=
strings
.
Replace
(
url
,
"https"
,
"wss"
,
1
)
}
else
if
strings
.
HasPrefix
(
url
,
"http"
)
{
...
...
This diff is collapsed.
Click to expand it.
cmd/logcli/main.go
+
20
−
9
View file @
03dc4e63
...
...
@@ -2,9 +2,10 @@ package main
import
(
"log"
"net/url"
"os"
kingpin
"gopkg.in/alecthomas/kingpin.v2"
"gopkg.in/alecthomas/kingpin.v2"
)
var
(
...
...
@@ -12,7 +13,9 @@ var (
quiet
=
app
.
Flag
(
"quiet"
,
"suppress everything but log lines"
)
.
Default
(
"false"
)
.
Short
(
'q'
)
.
Bool
()
outputMode
=
app
.
Flag
(
"output"
,
"specify output mode [default, raw, jsonl]"
)
.
Default
(
"default"
)
.
Short
(
'o'
)
.
Enum
(
"default"
,
"raw"
,
"jsonl"
)
addr
=
app
.
Flag
(
"addr"
,
"Server address."
)
.
Default
(
"https://logs-us-west1.grafana.net"
)
.
Envar
(
"GRAFANA_ADDR"
)
.
String
()
addr
=
app
.
Flag
(
"addr"
,
"Server address."
)
.
Default
(
"https://logs-us-west1.grafana.net"
)
.
Envar
(
"GRAFANA_ADDR"
)
.
String
()
addrURL
url
.
URL
username
=
app
.
Flag
(
"username"
,
"Username for HTTP basic auth."
)
.
Default
(
""
)
.
Envar
(
"GRAFANA_USERNAME"
)
.
String
()
password
=
app
.
Flag
(
"password"
,
"Password for HTTP basic auth."
)
.
Default
(
""
)
.
Envar
(
"GRAFANA_PASSWORD"
)
.
String
()
...
...
@@ -35,19 +38,27 @@ var (
ignoreLabelsKey
=
queryCmd
.
Flag
(
"exclude-label"
,
"Exclude labels given the provided key during output."
)
.
Strings
()
showLabelsKey
=
queryCmd
.
Flag
(
"include-label"
,
"Include labels given the provided key during output."
)
.
Strings
()
fixedLabelsLen
=
queryCmd
.
Flag
(
"labels-length"
,
"Set a fixed padding to labels"
)
.
Default
(
"0"
)
.
Int
()
labelsCmd
=
app
.
Command
(
"labels"
,
"Find values for a given label."
)
labelName
=
labelsCmd
.
Arg
(
"label"
,
"The name of the label."
)
.
HintAction
(
listLabels
)
.
String
()
labelsCmd
=
app
.
Command
(
"labels"
,
"Find values for a given label."
)
labelName
=
labelsCmd
.
Arg
(
"label"
,
"The name of the label."
)
.
HintAction
(
listLabels
)
.
String
()
)
func
main
()
{
log
.
SetOutput
(
os
.
Stderr
)
switch
kingpin
.
MustParse
(
app
.
Parse
(
os
.
Args
[
1
:
]))
{
cmd
:=
kingpin
.
MustParse
(
app
.
Parse
(
os
.
Args
[
1
:
]))
if
*
addr
==
""
{
log
.
Fatalln
(
"Server address cannot be empty"
)
}
u
,
err
:=
url
.
Parse
(
*
addr
)
if
err
!=
nil
{
log
.
Fatalf
(
"Failed to parse addr into URL: %v"
,
err
)
}
addrURL
=
*
u
switch
cmd
{
case
queryCmd
.
FullCommand
()
:
if
*
addr
==
""
{
log
.
Fatalln
(
"Server address cannot be empty"
)
}
doQuery
()
case
labelsCmd
.
FullCommand
()
:
doLabels
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment