# Is it possible to run a script prior to data being added to ES?

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-run-a-script-prior-to-data-being-added-to-es/83620>\
**Category:** Elasticsearch\
**Created:** [April 25, 2017, 9:40pm UTC](https://discuss.elastic.co/t/is-it-possible-to-run-a-script-prior-to-data-being-added-to-es/83620 "2017-04-25T21:40:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bobpurewal](https://avatars.discourse-cdn.com/v4/letter/b/c37758/32.png) [@bobpurewal](https://discuss.elastic.co/u/bobpurewal)\
**Post date:** [April 25, 2017, 9:40pm UTC](https://discuss.elastic.co/t/is-it-possible-to-run-a-script-prior-to-data-being-added-to-es/83620/1 "2017-04-25T21:40:32Z")

</div>

I'd like any responses to the HTTP request to be dependent on the client's IP address. That is, if the client has an authorized IP, we want the response to be delivered. However, if the IP is not authorized, we'd like there to be no response.

That's where I believe this script would come in. The script would check the header to validate the IP address.

I'm thinking of writing the script in either c# or python.

This is the way I picture the process to work:

- client makes an HTTP request
- script validates IP address
- if valid, response is allowed
- if not valid, response is suppressed and email alert is sent

My question is: is this possible?

I've been reading through the docs and I'm getting lost amongst the processors, the pipeline, and endpoints. ☹ I saw a mention that python was deprecated for ES5.0, so maybe using python is out.

Web development is not my strength, so my apologies if this question is nonsensical.

Thank you.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [April 25, 2017, 10:12pm UTC](https://discuss.elastic.co/t/is-it-possible-to-run-a-script-prior-to-data-being-added-to-es/83620/2 "2017-04-25T22:12:56Z")

</div>

This is usually something that would need to happen before it hits ES.

You could use the Security with Alerting to send the email. Otherwise you can build your own.

---

<div class="post-metadata">

**Author:** ![bobpurewal](https://avatars.discourse-cdn.com/v4/letter/b/c37758/32.png) [@bobpurewal](https://discuss.elastic.co/u/bobpurewal)\
**Post date:** [April 26, 2017, 2:46pm UTC](https://discuss.elastic.co/t/is-it-possible-to-run-a-script-prior-to-data-being-added-to-es/83620/3 "2017-04-26T14:46:23Z")

</div>

Thanks for the reply.  
Sounds like it's not possible to do, within ES.

---

<div class="post-metadata">

**Author:** ![wimvanleuven](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wimvanleuven/32/17617_2.png) [@wimvanleuven](https://discuss.elastic.co/u/wimvanleuven)\
**Post date:** [April 26, 2017, 4:14pm UTC](https://discuss.elastic.co/t/is-it-possible-to-run-a-script-prior-to-data-being-added-to-es/83620/4 "2017-04-26T16:14:07Z")

</div>

Just proxy your elasticsearch cluster with any proxy supporting server like httpd or nginx? Should be a piece of cake...

---

<div class="post-metadata">

**Author:** ![bobpurewal](https://avatars.discourse-cdn.com/v4/letter/b/c37758/32.png) [@bobpurewal](https://discuss.elastic.co/u/bobpurewal)\
**Post date:** [April 26, 2017, 4:46pm UTC](https://discuss.elastic.co/t/is-it-possible-to-run-a-script-prior-to-data-being-added-to-es/83620/5 "2017-04-26T16:46:32Z")

</div>

I am reading about httpd.

If I understand correctly, I can create a custom module for the apache server. As the server is going through it's processing phases, it will run my custom module. When the custom module runs, it determines whether the IP is authorized. It can then decide whether to allow the http reply? Am I understanding that correctly?

The reply part is where I'm having the most difficulty wrapping my head around this task.

I'd like the request to be logged in ES, regardless of whether the IP address is authorized or not.

Thanks for the reply. Much appreciated.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 24, 2017, 4:50pm UTC](https://discuss.elastic.co/t/is-it-possible-to-run-a-script-prior-to-data-being-added-to-es/83620/6 "2017-05-24T16:50:04Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
