Created
July 30, 2020 23:14
-
-
Save mdhighfi/4cf6fced742193fccc43ba75adde89b9 to your computer and use it in GitHub Desktop.
Copy/Paste the timestamps from a DataDog url
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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..)