Sometimes, the address object or service object search functionality in Junos Space Security Director might not return all results or correct results.
This article explains how the search index can be refreshed from the GUI as well as the Command Line Interface (CLI) in Junos Space Security Director 17.1R1 and later.
Note: From Junos Space Security Director version 17.1R1, Elasticsearch takes care of search and indexing.
Sometimes the search functionality in Junos Space Security Director does not return correct results, including that of objects that are known to exist, or were recently created.
Note : If you have a multi jboss node space deployment check the section below for multi-node space first.
Refresh SD Search index
Make note of the time you started this job to compare to logs
Verify Search index is complete
Monitor the logs for completion. (You can start this log tail before pressing re-index in UI)Note: The following command is checking 2 log files, depending on space version the log may be found in one log or the other. tail -f /var/log/jboss/servers/server1/server.log /var/log/jboss/servers/server1/SD.log | grep -i "full import"
tail -f /var/log/jboss/servers/server1/server.log /var/log/jboss/servers/server1/SD.log | grep -i "full import"
Index Start Example: WARN [net.juniper.jnap.sm.search.ejb.SearchAdminHandler] (Thread-1406 (HornetQ-client-global-threads-198019841)) Start Full Import Index Finish Example: WARN [net.juniper.jnap.sm.search.ejb.SearchAdminHandler] (Thread-1406 (HornetQ-client-global-threads-198019841)) Full Import Done
Index Start Example:
WARN [net.juniper.jnap.sm.search.ejb.SearchAdminHandler] (Thread-1406 (HornetQ-client-global-threads-198019841)) Start Full Import
Index Finish Example:
WARN [net.juniper.jnap.sm.search.ejb.SearchAdminHandler] (Thread-1406 (HornetQ-client-global-threads-198019841)) Full Import Done
Note: Make sure to check timestamp and compare to current time, as this searches all logs. grep -i "full import" /var/log/jboss/servers/server1/server.log* /var/log/jboss/servers/server1/SD.log* Search index data can be monitored for growth during indexing curl -XGET 'http://localhost:9200/_cat/indices?v' Example health status index uuid pri rep docs.count docs.deleted store.size pri.store.size green open security frBj647RTjqLvJl21MaItA 2 1 23208 1 7.2mb 7.2mb Notes Health should be green, if found to be yellow, attempt search re-index or contact JTACOnly index named "security" should be listed.Document count and size will grow periodically during re-index operation; though may pause for 5-10+ minutes between growth jumps depending on object count and system load
Note: Make sure to check timestamp and compare to current time, as this searches all logs.
grep -i "full import" /var/log/jboss/servers/server1/server.log* /var/log/jboss/servers/server1/SD.log*
Search index data can be monitored for growth during indexing
curl -XGET 'http://localhost:9200/_cat/indices?v'
Example
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size green open security frBj647RTjqLvJl21MaItA 2 1 23208 1 7.2mb 7.2mb
Notes
Check Disk space for /var Modifications to search index stop if jboss disk space reaches 90% for /var on any jboss nodeFrom Junos Space CLI
Filesystem Size Used Avail Use% Mounted on ..snip.. /dev/mapper/jmpvgnocf-lvvar 262G 44G 206G 18% /var
/var/log/elasticsearch/log-collector.log [2024-07-26T20:15:57,481][INFO ][o.e.c.r.a.DiskThresholdMonitor] [AAAAAAA] low disk watermark [90%] exceeded on [CCCCCCCCCCCCCCCCCCCC][AAAAAAA][/var/cache/secmgt-elastic-data/log-collector/nodes/0] free: 122.1gb[9.5%], replicas will not be assigned to this node [2024-07-26T20:15:57,481][INFO ][o.e.c.r.a.DiskThresholdMonitor] [BBBBBBB] low disk watermark [90%] exceeded on [DDDDDDDDDDDDDDDDDDDD][BBBBBBB][/var/cache/secmgt-elastic-data/log-collector/nodes/0] free: 119.2gb[9.3%], replicas will not be assigned to this node
Important: This message will only appear on the primary elastic search node. Which may not be the VIP or Jboss master (this is ok) Check all jboss nodes for this messageNote: Identifiers above will match with "_cluster/state/nodes" output below
Looking for Errors (Exceptions)
All Search logs: (note timestamps) grep -i SearchAdminHandler /var/log/jboss/servers/server1/server.log* /var/log/jboss/servers/server1/SD.log* Listing Exceptions only: grep -i SearchAdminHandler /var/log/jboss/servers/server1/server.log* /var/log/jboss/servers/server1/SD.log* | grep -i Exception Notes:Most common error will be timeout. Search index performance has been greatly enhanced for SD 19.1 and higher.Contact JTAC for workarounds, upgrade is recommended.
All Search logs: (note timestamps)
grep -i SearchAdminHandler /var/log/jboss/servers/server1/server.log* /var/log/jboss/servers/server1/SD.log*
grep -i
/var/log/jboss/servers/server1/server.log* /var/log/jboss/servers/server1/SD.log*
Listing Exceptions only:
grep -i SearchAdminHandler /var/log/jboss/servers/server1/server.log* /var/log/jboss/servers/server1/SD.log* | grep -i Exception
/var/log/jboss/servers/server1/server.log* /var/log/jboss/servers/server1/SD.log* | grep -i Exception
Login to Junos Space CLI, for each jboss node and use the following commands:
curl -XGET ' http://localhost:9200/_cluster/health?pretty 'Example: [root@space-5254004db3f8 ~]# curl -XGET 'http://localhost:9200/_cluster/health?pretty' { "cluster_name" : "log-collector", "status" : "green", <<< We want to see green here if all is well "timed_out" : false, "number_of_nodes" : 2, <<<< This line should match your number of Space Jboss nodes "number_of_data_nodes" : 2, "active_primary_shards" : 2, "active_shards" : 4, "relocating_shards" : 0, "initializing_shards" : 0, "unassigned_shards" : 0, "delayed_unassigned_shards" : 0, "number_of_pending_tasks" : 0, "number_of_in_flight_fetch" : 0, "task_max_waiting_in_queue_millis" : 0, "active_shards_percent_as_number" : 100.0 }
curl -XGET ' http://localhost:9200/_cluster/health?pretty 'Example:
[root@space-5254004db3f8 ~]# curl -XGET 'http://localhost:9200/_cluster/health?pretty' { "cluster_name" : "log-collector", "status" : "green", <<< We want to see green here if all is well "timed_out" : false, "number_of_nodes" : 2, <<<< This line should match your number of Space Jboss nodes "number_of_data_nodes" : 2, "active_primary_shards" : 2, "active_shards" : 4, "relocating_shards" : 0, "initializing_shards" : 0, "unassigned_shards" : 0, "delayed_unassigned_shards" : 0, "number_of_pending_tasks" : 0, "number_of_in_flight_fetch" : 0, "task_max_waiting_in_queue_millis" : 0, "active_shards_percent_as_number" : 100.0 }
curl -XGET 'http://localhost:9200/_cluster/state/nodes?pretty' Example: [root@space-5254004db3f8 ~]# curl -XGET 'http://localhost:9200/_cluster/state/nodes?pretty' { "cluster_name" : "log-collector", "nodes" : { "XKgBuPLUQn-OAtPgUo45ww" : { "name" : "XKgBuPL", "ephemeral_id" : "hLSJ06AKR_yp1gOQWyIM1A", "transport_address" : "10.85.216.134:9300", << Jboss Node IP "attributes" : { } }, "QmUxBA0YQ0S4IZz_koe1RA" : { "name" : "QmUxBA0", "ephemeral_id" : "wZrEb0_mQ0SA9sBCyJwruA", "transport_address" : "10.85.216.132:9300", << Jboss Node IP "attributes" : { } } } }
curl -XGET 'http://localhost:9200/_cluster/state/nodes?pretty'
[root@space-5254004db3f8 ~]# curl -XGET 'http://localhost:9200/_cluster/state/nodes?pretty' { "cluster_name" : "log-collector", "nodes" : { "XKgBuPLUQn-OAtPgUo45ww" : { "name" : "XKgBuPL", "ephemeral_id" : "hLSJ06AKR_yp1gOQWyIM1A", "transport_address" : "10.85.216.134:9300", << Jboss Node IP "attributes" : { } }, "QmUxBA0YQ0S4IZz_koe1RA" : { "name" : "QmUxBA0", "ephemeral_id" : "wZrEb0_mQ0SA9sBCyJwruA", "transport_address" : "10.85.216.132:9300", << Jboss Node IP "attributes" : { } } } }
Note: If upgrade to space platform was recently performed, each node must be rebooted as part of the upgrade, if the reboot was skipped. The required firewall rules to allow communication may not be active. Create Directory if it doesn't exist ls -l /etc/elasticsearch/discovery-file If not found: mkdir /etc/elasticsearch/discovery-file Create the IP list file vi /etc/elasticsearch/discovery-file/unicast_hosts.txt Add 1 line per IP, containing only the IP address Example: 10.85.216.132 10.85.216.134 Update elasticsearch.yml vi /etc/elasticsearch/elasticsearch.yml Add the following line to the bottom of the file only if it is not present (Check the complete content of the file) discovery.zen.hosts_provider: file Update Permissions chown -R elasticsearch:space /etc/elasticsearch/discovery-file chmod 750 /etc/elasticsearch/discovery-file chmod 755 /etc/elasticsearch/discovery-file/unicast_hosts.txt Restart elasticsearch on all nodes. The system will take a few minutes to restart and find each node. service elasticsearch restart Check the command output from Step 2, All nodes should now be seen in the output. (This may take 1-10 minutes before processes completely start and find each other depending on environment) curl -XGET 'http://localhost:9200/_cluster/state Refresh search index from web UI following steps above The Refresh Search Index CLI procedure for Junos Space 16.1R3 and earlier is detailed here: KB30468 - Junos Space Security Director re-index object search [juniper.net] .
ls -l /etc/elasticsearch/discovery-file If not found: mkdir /etc/elasticsearch/discovery-file
ls -l /etc/elasticsearch/discovery-file
If not found:
mkdir /etc/elasticsearch/discovery-file
vi /etc/elasticsearch/discovery-file/unicast_hosts.txt Add 1 line per IP, containing only the IP address Example: 10.85.216.132 10.85.216.134
vi /etc/elasticsearch/discovery-file/unicast_hosts.txt
Add 1 line per IP, containing only the IP address
Example:
10.85.216.132 10.85.216.134
vi /etc/elasticsearch/elasticsearch.yml Add the following line to the bottom of the file only if it is not present (Check the complete content of the file) discovery.zen.hosts_provider: file
vi /etc/elasticsearch/elasticsearch.yml
Add the following line to the bottom of the file only if it is not present (Check the complete content of the file)
discovery.zen.hosts_provider: file
chown -R elasticsearch:space /etc/elasticsearch/discovery-file chmod 750 /etc/elasticsearch/discovery-file chmod 755 /etc/elasticsearch/discovery-file/unicast_hosts.txt
service elasticsearch restart
curl -XGET 'http://localhost:9200/_cluster/state
The Refresh Search Index CLI procedure for Junos Space 16.1R3 and earlier is detailed here: KB30468 - Junos Space Security Director re-index object search [juniper.net] .
2023-08-24: Added a clarification: "Add the following line to the bottom of the file only if it is not present (Check the complete content of the file)"
2019-07-17: Clarified verification steps, added how to check for errors, and added Cluster formation check and correction