-
Notifications
You must be signed in to change notification settings - Fork 66
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
Added in parameter enabled timeframe support #111
base: main
Are you sure you want to change the base?
Conversation
These changes allow a user to specify a timeframe, in either seconds or milliseconds, to poll an API that requires timestamps as a parameter. Example: https://docs.umbrella.com/umbrella-api/docs/security-activity-report
Instead of hard-coded Seconds/Milliseconds, I've opted to allow the time_format to be user set to any Ruby supported format, which should allow much more flexibility for URL formatting.
Forgot to set a default to the parameter, resulting in a nul pointer. My bad.
I found out that, seemingly, in the case of having several instances of http_poller or multiple URLs, the modifcations to the URL wasn't happening, so now there is support for dealing with the request arrays, along with a micro optimization of only running gsub what the text we're replacing is actually there.
It looks like I may have an issue consistently updating the value; I'll look into it next week. |
I observed some situations where the URL was being set only at the first run, resulting in a failure to obtain new results as time moved forward. I added in some code to both failure and success to make sure the URL was reset after every run.
Adjusting whitespace, nothing to see here.
After doing some additional testing, it turns out I don't need a loop, but I left it in as a comment for reference.
Nice this looks great |
Nice work, but why so specific (forward time and backward time). Don't we only need a way to store last cycle values ? Not all api's are the same, in the case of the reddit api they use after and before keys which are unique ids and not dates. https://www.reddit.com/dev/api/ All I would like to see is a way to keep a last run value just like the JDBC input plugin (state / sql_last_value). https://www.elastic.co/guide/en/logstash/current/plugins-inputs-jdbc.html#_state Found the ruby code here related to sql_last_value which they store in a last run state file: Would this not simplify the code ? |
Does this work if you want to put the variable in the body as well? |
@hiven Not at the moment, but should be doable; I'd just need to find what part of the request array it's stored in (which might make sense to put the loop back in so it can look at everything). @chrisribe I suppose it's specific because it fitted the parameters I needed. I originally wrote a ruby script to deal with DUO admin APIs, but when I had to look at pulling other, slightly simpler APIs (DUO has this whole transaction code thing in their APIs (https://github.com/duosecurity/duo_api_ruby/blob/master/lib/duo_api.rb) I found that the ones I was looking at were filterable by timeframes, which was my path of least resistance. I'm not opposed to putting in a 'last ran' tracker (which looks like just writing data to a file in the jdbc) but it'd take me a little bit of time to do so. Based on the quick glance at the reddit API, if I can get a 'last ran' tracker up, it should be pretty simple to setup the text swapping. |
Any plan on merging this? @colinsurprenant |
These changes allow a user to specify a timeframe, in either seconds or milliseconds, to poll an API that requires timestamps as a parameter. Example: https://docs.umbrella.com/umbrella-api/docs/security-activity-report
Obviously I didn't change the asciidoc, nor the spec, but I approached this as solving a problem I had.
Here's an example use: