vector icon indicating copy to clipboard operation
vector copied to clipboard

VRL web playground timezone option / menu configuration

Open DimDroll opened this issue 1 month ago • 1 comments

Hello Vector Team,

Thank you for great web playground that you host free of charge here: https://playground.vrl.dev/

I'm located in non-UTC aligned country and when I test timestamp transformation with timezone I get this:

{
	"foo": "delete me",
	"http_status": "200",
	"message": "Hello VRL",
	"vector_timezone": "Europe/Kiev"
}

from:

.vector_timezone = get_timezone_name!()

For some edge cases where I need to test different timezone like the one I run on my servers (UTC) there is no easy way to do it.

Currently I found a place to modify it for my local playground run in: https://github.com/vectordotdev/vector/blob/3da355b0bde93ed2afa643c53e32b84ac387fd4f/lib/vector-vrl/web-playground/src/lib.rs#L88

vector❯ git diff lib/vector-vrl/web-playground/src/lib.rs
diff --git a/lib/vector-vrl/web-playground/src/lib.rs b/lib/vector-vrl/web-playground/src/lib.rs
index a434050ae..97b084aaa 100644
--- a/lib/vector-vrl/web-playground/src/lib.rs
+++ b/lib/vector-vrl/web-playground/src/lib.rs
@@ -85,8 +85,8 @@ fn compile(mut input: Input) -> Result<VrlCompileResult, VrlDiagnosticResult> {
     let state = TypeState::default();
     let mut runtime = Runtime::default();
     let config = CompileConfig::default();
-    let timezone = TimeZone::default();
-
+//    let timezone = TimeZone::default();
+    let timezone = TimeZone::parse("UTC").expect("Failed to parse timezone");
     let mut target_value = TargetValue {
         value: event.clone(),
         metadata: Value::Object(BTreeMap::new()),

I would like to suggest a feature to have UI switch / configuration option where I could choose from a dropdown either use my local timezone by default or switch to UTC (as this is the most common timezone wordwide for servers).

Thank you!

p.s. timezone can be set in vector configuration globally, but for playground unfortunately, in remap specifically there is no way to set it. maybe as more solid approach playground could support vector configuration file to be uploaded and used to customize settings that are not available in remap.

DimDroll avatar Jun 04 '24 07:06 DimDroll