Search with Elasticsearch
We need more data in Elasticsearch to make the search and graph more interesting. I would recommend reloading a few of the lab devices to have the log entries for interface resets, BGP and OSPF establishments, as well as device boot up messages. Otherwise, feel free to use the sample data we imported at the beginning of this chapter for this section.
If we look back at the Chapter12_2.py
script example, when we did the search, there were two pieces of information that could potentially change from each query; the index and query body. What I typically like to do is to break that information into input variables that I can dynamically change at runtime to separate the logic of the search and the script itself. Let's make a file called query_body_1.json
:
{
"query": {
"match_all": {}
}
}
We will create a script, Chapter12_3.py
, that uses argparse
to take the user input at the command line:
import...