Skip to content

Instantly share code, notes, and snippets.

@mdhighfi
Created July 30, 2020 23:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdhighfi/4cf6fced742193fccc43ba75adde89b9 to your computer and use it in GitHub Desktop.
Save mdhighfi/4cf6fced742193fccc43ba75adde89b9 to your computer and use it in GitHub Desktop.
Copy/Paste the timestamps from a DataDog url
const from_ts = /from_ts=(\d+)/;
const to_ts = /to_ts=(\d+)/;
const live = /live=(true|false)/;
let url = window.location.href;
function originalFrom(){
return url.match(from_ts)[1];
}
function originalTo(){
return url.match(to_ts)[1];
}
alert("from_ts=" + originalFrom() + "&to_ts=" + originalTo())
let paramsInput = window.prompt("Paste timestamp params")
const from_ts_re = /from_ts=(\d+)/;
const to_ts_re = /to_ts=(\d+)/;
const live_re = /live=(true|false)/;
let url = window.location.href;
function baseURL(){
return url.replace(from_ts_re, "").replace(to_ts_re, "").replace(live_re,'').replace('&&', '').replace('?&', '').replace(/&$/,'');
}
function resultUrl(from, to){
let from_ts = paramsInput.match(from_ts_re)[1];
let to_ts = paramsInput.match(to_ts_re)[1];
return baseURL() + '&from_ts=' + from_ts + '&to_ts=' + to_ts + '&live=false';
}
window.location.href = resultUrl();
@RafaAguilar
Copy link

Just wanted to say... thanks, &live=false was the key in my issue, datadog dashboards kept modifying the from_ts and to_ts to current hour T_T (pain..)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment