Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CurrentDate %{+yyyy-MM-dd} not supported in input #108

Open
romlod opened this issue Feb 26, 2019 · 2 comments
Open

CurrentDate %{+yyyy-MM-dd} not supported in input #108

romlod opened this issue Feb 26, 2019 · 2 comments
Assignees

Comments

@romlod
Copy link

romlod commented Feb 26, 2019

When performing a SOAP call, it looks like %{+yyyy-MM-dd} for getting the currentDate in the body doesn't seem to work. I don't know whether this is expected behaviour or some sort of bug. Example below:

input {
  http_poller {
	add_field => {"[basedateSOAP]" => "%{+YYYY-MM-dd}"}
	add_field => {"[requestSOAP]" => '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header></soapenv:Header><soapenv:Body><type><Start_Date>%{[basedateSOAP]}</Start_Date><End_Date>%{[basedateSOAP]}</End_Date></type></soapenv:Body></soapenv:Envelope>'}
	urls => { 
	soap_request => {
	method => post
	url => "https:/test.com"
	headers => {
	"Content-Type" => "text/xml; charset=utf-8"
	}
	#body => '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header></soapenv:Header><soapenv:Body><type><Start_Date>%{[basedateSOAP]}</Start_Date><End_Date>%{[basedateSOAP]}</End_Date></type></soapenv:Body></soapenv:Envelope>'	
	body => "%{[requestSOAP]}"
}}   


request_timeout => 60
schedule => { cron => "* * * * * UTC"}
codec => "plain"
  }
}
@hiven
Copy link

hiven commented Jun 3, 2019

This is driving us mad. Would love this to be fixed as it makes the product useless for our need since we use the current date as part of our body to pull the current logs.

@guyboertje
Copy link

guyboertje commented Jun 4, 2019

%{+YYYY-MM-dd} is an interpolation of a date and/or time - but the important part is to know which date is used. As this interpolation is used (and was designed) for creating a text with the date/time taken from the current event (so that, for example, events can be steered to different dated indexes) it uses the @timestamp field of the current event.
Because inputs generate events there is no event and @timestamp field to use to build the interpolation when the input config is compiled.

Because of this limitation, only some settings are interpolated and which ones those are is the decision of the plugin author. That is, one can't assume that all settings are interpolated.

One could argue that the interpolation should use Time.now() if an event is not available but this would be a new piece of code (for inputs to use) because now the sprintf method is defined on the Event class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants