Skip to main content
Solved

Cribl Stream: Dynamic Unix Epoch Time for REST Collector collect

  • Nov 4, 2026 11:52 AM UTC
  • 14 replies
  • 3 views

This message originated from Cribl Community Slack.
Click here to view the original link.

Good morning, I am working on configuring a REST Collector for retrieving Akamai EAA logs. I have gotten it to successfully connect and retrieve logs when inputting a static start and end time in the collect parameters, using Unix Epoch Time. I cannot, however, figure out what I am doing wrong in getting it to work with an expression to add a dynamic value for those start and end collect parameters. Has anyone worked out the expression for dynamic Unix Epoch Time creation that works within the collect parameters in the REST collector? Would be incredibly helpful Thanks in advance.

Best answer by Jon Rust

JS fields should default to interpreting as JS expressions. For boring and tedious reasons there are some cases where Stream tries to be smart and figure out if you want an expression or a string. Safest way is to always wrap in back ticks as you showed above.
View original

14 replies

Jon Rust
Forum|alt.badge.img
  • Employee
  • Nov 4, 2026 11:52 AM UTC
Please share the config and what you're trying to do

This is what I am working with. I am trying to get the collectRequestParams end/Start values to be dynamic, not static. They have to be in Unix Epoch Time format, which is seemingly more difficult than I expected, or I am just missing something obvious. "collectRequestParams": [ { "name": "contractId", "value": "'M-20EGWM5'" }, { "name": "end", "value": "'${params.end = Math.floor(Date.now() / 1000)}'" }, { "name": "start", "value": "'${params.start = Math.floor((Date.now() - 300000) / 1000)}'" }

Links for this message:
Untitled

Jon Rust
Forum|alt.badge.img
  • Employee
  • Nov 4, 2026 11:52 AM UTC
earliest and latest are how you reference the time supplied the interface in cribl. They are provided in epoch (seconds since 1970)

Jon Rust
Forum|alt.badge.img
  • Employee
  • Nov 4, 2026 11:52 AM UTC
So for example:
          "name": "start",
          "value": earliest

Jon Rust
Forum|alt.badge.img
  • Employee
  • Nov 4, 2026 11:52 AM UTC
and
        {
          "name": "end",
          "value": latest
        },

Jon Rust
Forum|alt.badge.img
  • Employee
  • Nov 4, 2026 11:52 AM UTC
if you'd rather do some math to dynamically calculate earliest and latest, you can calculate as below. Maybe you're running every 5 minutes and want the last 5 minutes (with a 1 minute buffer) Start: Date.now()/1000 - 360 End: Date.now()/1000 - 60

I tried that method actually, and it adds it to the request as such, generating this error: http error, statusCode: 401, details: {"host":"akab-ibzz4wjfuyo7tfjx-xuha46doyr7vm4ja.luna.akamaiapis.net","port":"","path":"/crux/v1/mgmt-pop/application-reports/ops/query?contractId=M-20EGWM5&end=latest&start=earliest","method":"get"}

Jon Rust
Forum|alt.badge.img
  • Employee
  • Nov 4, 2026 11:53 AM UTC
you may need to round/truncate the epoch time so it's an integer not float

Jon Rust
Forum|alt.badge.img
  • Employee
  • Nov 4, 2026 11:53 AM UTC
Start: Math.round(Date.now()/1000) - 360

Jon Rust
Forum|alt.badge.img
  • Employee
  • Nov 4, 2026 11:53 AM UTC
If you use the earliest and latest params in the collector settings, you get the epoch time, and any offsets, simpler. Just reference the earliest and latest values

I guess I am confused. When I put those in the collector parameters in the UI, it just shows them as a string into the Collect URL and then I get the 401 error.

Ok, I figured it out. Should be input into the value field as ${Math.round(Date.now()/1000) - 360}``

Jon Rust
Forum|alt.badge.img
  • Employee
  • Answer
  • Nov 4, 2026 11:53 AM UTC
JS fields should default to interpreting as JS expressions. For boring and tedious reasons there are some cases where Stream tries to be smart and figure out if you want an expression or a string. Safest way is to always wrap in back ticks as you showed above.

I originally had tried it, but I did not use the right "tick" which is what threw me off. Thanks for your help Jon!