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
96223322
Commit
96223322
authored
6 years ago
by
Tom Wilkie
Browse files
Options
Downloads
Patches
Plain Diff
Make queries take nanoseconds since epoch.
Signed-off-by:
Tom Wilkie
<
tom.wilkie@gmail.com
>
parent
6f883b33
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
README.md
+2
-2
2 additions, 2 deletions
README.md
pkg/querier/http.go
+5
-5
5 additions, 5 deletions
pkg/querier/http.go
with
7 additions
and
7 deletions
README.md
+
2
−
2
View file @
96223322
...
...
@@ -89,8 +89,8 @@ There are 4 API endpoints:
For doing queries, accepts the following paramters in the query-string:
-
`query`
: a logQL query
-
`limit`
: max number of entries to return
-
`start`
: the start time for the query, as a Unix epoch (seconds since 1970)
-
`end`
: the end time for the query, as a Unix epoch (seconds since 1970)
-
`start`
: the start time for the query, as a
nanosecond
Unix epoch (
nano
seconds since 1970)
-
`end`
: the end time for the query, as a
nanosecond
Unix epoch (
nano
seconds since 1970)
-
`direction`
:
`forward`
or
`backward`
, useful when specifying a limit
-
`regexp`
: a regex to filter the returned results, will eventually be rolled into the query language
...
...
This diff is collapsed.
Click to expand it.
pkg/querier/http.go
+
5
−
5
View file @
96223322
...
...
@@ -28,18 +28,18 @@ func intParam(values url.Values, name string, def int) (int, error) {
return
strconv
.
Atoi
(
value
)
}
func
unixTimeParam
(
values
url
.
Values
,
name
string
,
def
time
.
Time
)
(
time
.
Time
,
error
)
{
func
unix
Nano
TimeParam
(
values
url
.
Values
,
name
string
,
def
time
.
Time
)
(
time
.
Time
,
error
)
{
value
:=
values
.
Get
(
name
)
if
value
==
""
{
return
def
,
nil
}
sec
s
,
err
:=
strconv
.
ParseInt
(
value
,
10
,
64
)
nano
s
,
err
:=
strconv
.
ParseInt
(
value
,
10
,
64
)
if
err
!=
nil
{
return
time
.
Time
{},
err
}
return
time
.
Unix
(
secs
,
0
),
nil
return
time
.
Unix
(
0
,
nanos
),
nil
}
func
directionParam
(
values
url
.
Values
,
name
string
,
def
logproto
.
Direction
)
(
logproto
.
Direction
,
error
)
{
...
...
@@ -65,13 +65,13 @@ func (q *Querier) QueryHandler(w http.ResponseWriter, r *http.Request) {
}
now
:=
time
.
Now
()
start
,
err
:=
unixTimeParam
(
params
,
"start"
,
now
.
Add
(
-
defaulSince
))
start
,
err
:=
unix
Nano
TimeParam
(
params
,
"start"
,
now
.
Add
(
-
defaulSince
))
if
err
!=
nil
{
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusBadRequest
)
return
}
end
,
err
:=
unixTimeParam
(
params
,
"end"
,
now
)
end
,
err
:=
unix
Nano
TimeParam
(
params
,
"end"
,
now
)
if
err
!=
nil
{
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusBadRequest
)
return
...
...
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