This is the multi-page printable view of this section. Click here to print.
Indexing data
- 1: Shared Index Volumes
- 2: Elasticsearch
- 2.1: Introduction
- 2.2: Getting Started
- 2.3: Indexing data
- 2.4: Exploring Data in Kibana
- 3: Lucene Indexes
- 4: Solr Integration
1 - Shared Index Volumes
A Lucene
Index
Index
- Local - A disk that only one node can see. The volume belongs to that node. Only that node can write to its shards or search them.
- Shared - One mount that every node can see, e.g. a network file system. The volume has no node. Any node can search its shards and any node can write to them.
Shared index volumes are new in v7.14. Every index volume that existed before v7.14 is local and behaves as it always did.
Why Use a Shared Volume
With local volumes a shard can only be reached through the node that wrote it.
- If a node is down, searches return no results from its shards until it is back.
- If a node is lost for good, so are its shards.
- The node that wrote the most shards does the most searching.
With a shared volume a shard does not belong to a node.
- A search does not depend on the node that wrote a shard being up.
- A node that is added to the cluster can search and write to the existing shards straight away.
- A node that dies does not take its shards with it. Another node takes them on, and the streams the dead node had not finished indexing are indexed again.
Requirements
A shared volume must be a file system that:
- Is mounted at the same path on every node.
- Every node can read from and write to.
- Shows a file written by one node to the other nodes.
A relative path is resolved against the Stroom home directory of each node.
Warning
Creating a Shared Volume
Index volumes are managed from the main menu:
To add a shared volume to a
Volume group
Volume group
To turn local volumes into a shared volume, edit one of them and change its Type to Shared. This is the way to do it when the nodes already have local volumes with the same path and that path is in fact one mount. The volumes that the other nodes have in the group for that path are merged into the one shared volume, and their shards become shards of the shared volume.
The following rules apply:
- A shared volume cannot be made local again, because its shards may have been written by any node. Add a new local volume instead.
- A volume group cannot have a shared volume and a local volume with the same path. Mark the local volume as shared rather than adding a new one.
- A volume group can have both shared and local volumes. New shards are created on its shared volumes when it has any. If none of its shared volumes can take a shard, e.g. because they are all full, new shards are created on the node’s local volumes.
Checks on a Shared Volume
When a volume is marked as shared, each node checks that it can create the path and write to it. The change is refused if any node cannot. A node that cannot be reached cannot be checked, so Stroom names it and asks you to confirm the change.
After that, the job Index Volume Status on each node keeps a marker file in each shared volume and looks for the markers of the other running nodes. If a node cannot see the marker of another running node after 15 minutes, it logs an error that says the path is probably not the same mount on every node. A node that is down is not expected to keep its marker fresh.
Searching
A shard on a shared volume is searched by one of the nodes that are running, which need not be the node that wrote it.
- A closed shard is given to a running node that is chosen from the ID of the shard. A shard goes to the same node from one search to the next, which keeps the file cache of that node warm. When a node joins or leaves the cluster, only the shards that it gains or loses move.
- A shard that is open for writing is searched by the node that is writing to it, because only that node sees the documents that are not yet committed. If that node is not running, the shard is searched by another node as far as its last commit.
If a search cannot be started on a node, the shards on shared volumes that it would have searched are searched by other nodes.
A node that is writing to a shard replaces the files of the shard as it commits and merges.
Another node may be part way through reading those files, so the writer keeps what it has replaced for a period before it deletes it.
The period is set by the property stroom.index.writer.replacedCommitRetention and is 30 minutes by default.
It must be longer than the longest time that a search holds a shard open.
A longer period uses more disk space.
Writing
Only one node can write to a shard at a time. A node must hold a lease on a shard on a shared volume to write to it.
- A node claims the lease when it opens the shard for writing.
- It renews the lease while the shard is open.
How often is set by
stroom.index.writer.shardLeaseRenewInterval, which is 20 seconds by default. - It gives the lease up when it closes the shard. Any node can then write to the shard.
- A lease that is not renewed runs out.
How long that takes is set by
stroom.index.writer.shardLeaseDuration, which is 1 minute by default.
When a node needs a shard to write to, it uses a closed shard that has room in it before it creates a new one. A shard is therefore written to by different nodes over its life. The Node shown for a shard on a shared volume is the node that holds its lease, or the last one that did.
Shards on local volumes have no lease.
When a Node Fails
A Node That Cannot Renew Leases
A node that cannot reach the database cannot renew its leases. Once it has been unable to renew a lease for three quarters of the lease duration it stops writing to the shard. It discards the documents that it has not committed and it no longer changes any file in the shard. The streams those documents came from are indexed again, see Re-Indexed Streams.
A Node That Has Died
A node that has died leaves its shards open, with leases that run out. Until they are taken from it, new documents go to other shards.
Once a lease has been out of date for a grace period, the shard is taken from the node. The shard is closed, any node can write to it again, and the streams the dead node had not committed are indexed again. This is done by the job Index Shard Stream Recovery, which runs every minute. The job must be enabled on every node that can reach the shared volume, because the streams of a shard that has been taken are recovered by one of the running nodes.
The grace period is set by stroom.index.writer.shardLeaseTakeoverGrace and is 5 minutes by default.
It is the margin for a node that was frozen rather than dead and wakes later, so it must be much longer than any pause a node could suffer.
A node that comes back after its shards have been taken does not commit what it had not committed, and does not change the files of those shards.
Re-Indexed Streams
Documents are added to a shard as a stream is processed, but they are only safe once the shard has committed them. Stroom records which streams have documents in a shard that are not yet committed. This applies to shards on both shared and local volumes.
A stream is indexed again if:
- Its indexing task fails part way through the stream.
- A shard that holds some of its documents fails to commit.
- The writer of a shard that holds some of its documents stops without a final commit, e.g. because its node died or lost its lease.
When that happens:
- The documents of the stream are removed from every shard that they were written to.
- The processor task for the stream is put back to run again.
- An Error stream is written for the stream that says why. It is removed when the task next runs.
After three failed attempts the task is set to Failed rather than run again.
Note
Limits
- Documents are removed by their stream ID. Removing a stream removes every document in the index that came from it.
- The index must have an indexed
StreamIdfield for the documents of a stream to be found and removed. - Only streams that are indexed by a
processor filter
Processor filter
A Processor Filter is used to used to find Streams to process through the Pipeline associated with the Processor Filter. A Processor Filter consists of an expression tree to select which Streams to process and a tracker to track the what Streams have been processed.Click to see more details... are recorded.
Shard Housekeeping
A shard on a local volume is looked after by its own node. A shard on a shared volume is looked after by one of the running nodes, which need not be the node that wrote it. While a shard is open for writing, that is the node that is writing to it. That node applies the retention period of the index to the shard, deletes its files once it has been deleted, and acts on requests to flush or delete it. The jobs Index Shard Retention, Index Shard Delete and Index Shard Stream Recovery must therefore be enabled on every node that can reach the shared volume.
Properties
All of these are under stroom.index.writer.
| Property | Default | Description |
|---|---|---|
replacedCommitRetention |
PT30M |
How long a writer keeps the files it has replaced in a shard, for searches on other nodes to finish. |
shardLeaseDuration |
PT1M |
How long a lease on a shard lasts if it is not renewed. |
shardLeaseRenewInterval |
PT20S |
How often a node renews its leases. This should be about a third of shardLeaseDuration. |
shardLeaseTakeoverGrace |
PT5M |
How long a lease must have been out of date before the shard is taken from the node that held it. |
2 - Elasticsearch
2.1 - Introduction
Stroom supports using an external Elasticsearch cluster to index event data. This allows you to leverage all the features of the Elastic Stack, such as shard allocation, replication, fault tolerance and aggregations.
With Elasticsearch as an external service, your search infrastructure can scale independently of your Stroom data processing cluster, enhancing interoperability with other platforms by providing a performant and resilient time-series event data store. For instance, you can:
- Deploy Kibana to search and visualise Elasticsearch data.
- Index Stroom’s stream meta and
Errorstreams so monitoring systems can generate metrics and alerts. - Use Apache Spark to perform stateful data processing and enrichment, through the use of the Elasticsearch-Hadoop connector.
Stroom achieves indexing and search integration by interfacing securely with the Elasticsearch REST API using the Java high-level client.
This guide will walk you through configuring a Stroom indexing pipeline, creating an Elasticsearch index template, activating a stream processor and searching the indexed data in both Stroom and Kibana.
Assumptions
- You have created an Elasticsearch cluster. Elasticsearch 8.x is recommended, though the latest supported 7.x version will also work. For test purposes, you can quickly create a single-node cluster using Docker by following the steps in the Elasticsearch Docs .
- The Elasticsearch cluster is reachable via HTTPS from all Stroom nodes participating in stream processing.
- Elasticsearch security is enabled. This is mandatory and is enabled by default in Elasticsearch 8.x and above.
- The Elasticsearch HTTPS interface presents a trusted X.509 server certificate. The Stroom node(s) connecting to Elasticsearch need to be able to verify the certificate, so for custom PKI, a Stroom truststore entry may be required.
- You have a feed containing
Eventstreams to index.
Key Differences
Indexing data with Elasticsearch differs from Solr and built-in Lucene methods in a number of ways:
- Unlike with Solr and built-in Lucene indexing, Elasticsearch field mappings are managed outside Stroom, through the use of index and component templates . These are normally created either via the Elasticsearch API, or interactively using Kibana.
- Aside from creating the mandatory
StreamIdandEventIdfield mappings, explicitly defining mappings for other fields is optional. Elasticsearch will use dynamic mapping by default, to infer each field’s type at index time. Explicitly defining mappings is recommended where consistency or greater control are required, such as for IP address fields (Elasticsearch mapping typeip).
Next page - Getting Started
2.2 - Getting Started
Establish an Elasticsearch Cluster Connection in Stroom
The first step is to configure Stroom to connect to an Elasticsearch cluster.
You can configure multiple cluster connections if required, such as a separate one for production and another for development.
Each cluster connection is defined by an Elastic Cluster document within the Stroom UI.
- In the Stroom Explorer pane (), right-click on the folder where you want to create the
Elastic Clusterdocument. - Select:
- Give the cluster document a name and press .
- Complete the fields as explained in the section below. Any fields not marked as “Optional” are mandatory.
- Click
Test Connection. A dialog will display with the test result. IfConnection Success, details of the target cluster will be displayed. Otherwise, error details will be displayed. - Click to commit changes.
Warning
Elastic Cluster document.
The Read privilege permits retrieval of the Elasticsearch API key and secret, granting the holder the same level of privilege as Stroom.
Users authorised to search Elasticsearch indices via Stroom dashboards should only be assigned the Use privilege.
Elastic Cluster Document Fields
Description
(Optional) You might choose to enter the Elasticsearch cluster name or purpose here.
Connection URLs
Enter one or more node or cluster addresses, including protocol, hostname and port. Only HTTPS is supported; attempts to use plain-text HTTP will fail.
Examples
- Local development node:
https://localhost:9200 - FQDN:
https://elasticsearch.example.com:9200 - Kubernetes service:
https://prod-es-http.elastic.svc:9200
CA Certificate
PEM-format CA certificate chain used by Stroom to verify TLS connections to the Elasticsearch HTTPS REST interface. This is usually your organisation’s root enterprise CA certificate. For development, you can provide a self-signed certificate.
Use Authentication
(Optional) Tick this box if Elasticsearch requires authentication. This is enabled by default from Elasticsearch version 8.0.
API Key ID
Required if Use authentication is checked.
Specifies the Elasticsearch API key ID for a valid Elasticsearch user account.
This user requires at a minimum the following
privileges
:
Cluster Privileges
- monitor
- manage_own_api_key
Index Privileges
- all
API Key Secret
Required if Use authentication is checked.
Socket Timeout (ms)
Number of milliseconds to wait for an Elasticsearch indexing or search REST call to complete.
Set to -1 (the default) to wait indefinitely, or until Elasticsearch closes the connection.
Next page - Indexing data
2.3 - Indexing data
A typical workflow is for a Stroom pipeline to convert XML Event elements into the XML equivalent of JSON, complying with the schema http://www.w3.org/2005/xpath-functions, using a format identical to the output of the XML function xml-to-json().
Understanding JSON XML Representation
In an Elasticsearch indexing pipeline translation, you model JSON documents in a compatible XML representation.
Common JSON primitives and examples of their XML equivalents are outlined below.
Arrays
Array of maps
<array key="users" xmlns="http://www.w3.org/2005/xpath-functions">
<map>
<string key="name">John Smith</string>
</map>
</array>
Array of strings
<array key="userNames" xmlns="http://www.w3.org/2005/xpath-functions">
<string>John Smith</string>
<string>Jane Doe</string>
</array>
Maps and Properties
<map key="user" xmlns="http://www.w3.org/2005/xpath-functions">
<string key="name">John Smith</string>
<boolean key="active">true</boolean>
<number key="daysSinceLastLogin">42</number>
<string key="loginDate">2022-12-25T01:59:01.000Z</string>
<null key="emailAddress" />
<array key="phoneNumbers">
<string>1234567890</string>
</array>
</map>
Note
JSON), to make it easier to diagnose JSON conversion errors.
We will now explore how to create an Elasticsearch index template, which specifies field mappings and settings for one or more indices.
Create an Elasticsearch Index Template
For information on what index and component templates are, consult the Elastic documentation .
When Elasticsearch first receives a document from Stroom targeting an index, whose name matches any of the index_patterns entries in the index template, it will create a new index / data stream using the settings and mappings properties from the template.
In this way, the index does not need to be manually created in advance.
Note
5, the indexing and search performance will likely be inadequate for large indices.
The following example creates a basic index template stroom-events-v1 in a local Elasticsearch cluster, with the following explicit field mappings:
StreamId– mandatory, data typelongorkeyword.EventId– mandatory, data typelongorkeyword.@timestamp– required if the index is to be part of a data stream (recommended).User– An object containing propertiesId,NameandActive, each with their own data type.Tags– An array of one or more strings.Message– Contains arbitrary content such as unstructured raw log data. Supports full-text search. Nested fieldwildcardsupports regexp queries .
Note
array field mapping data type.
An Elasticsearch field may contain zero or more values by default.
See:
Arrays
in the Elastic documentation.
In Kibana Dev Tools, execute the following query:
PUT _index_template/stroom-events-v1
{
"index_patterns": [
"stroom-events-v1*" // Apply this template to index names matching this pattern.
],
"data_stream": {}, // For time-series data. Recommended for event data.
"template": {
"settings": {
"number_of_replicas": 1, // Replicas impact indexing throughput. This setting can be changed at any time.
"number_of_shards": 10, // Consider the shard sizing guide: https://www.elastic.co/guide/en/elasticsearch/reference/current/size-your-shards.html#shard-size-recommendation
"refresh_interval": "10s", // How often to refresh the index. For high-throughput indices, it's recommended to increase this from the default of 1s
"lifecycle": {
"name": "stroom_30d_retention_policy" // (Optional) Apply an ILM policy https://www.elastic.co/guide/en/elasticsearch/reference/current/set-up-lifecycle-policy.html
}
},
"mappings": {
"dynamic_templates": [],
"properties": {
"StreamId": { // Required.
"type": "long"
},
"EventId": { // Required.
"type": "long"
},
"@timestamp": { // Required if the index is part of a data stream.
"type": "date"
},
"User": {
"properties": {
"Id": {
"type": "keyword"
},
"Name": {
"type": "keyword"
},
"Active": {
"type": "boolean"
}
}
},
"Tags": {
"type": "keyword"
},
"Message": {
"type": "text",
"fields": {
"wildcard": {
"type": "wildcard"
}
}
}
}
}
},
"composed_of": [
// Optional array of component template names.
]
}
Create an Elasticsearch Indexing Pipeline Template
An Elasticsearch indexing pipeline is similar in structure to the built-in packaged Indexing template pipeline.
It typically consists of the following pipeline elements:
-
XSLTFilter
contains the translation mapping
Eventsto JSONarray. -
SchemaFilter
uses schema group
JSON.
It is recommended to create a template Elasticsearch indexing pipeline, which can then be re-used.
Procedure
- Right-click on the
Template Pipelinesfolder in the Stroom Explorer pane (). - Select:
- Enter the name
Indexing (Elasticsearch)and click . - Define the pipeline structure as above, and customise the following pipeline elements:
- Set the Split Filter
splitCountproperty to a sensible default value, based on the expected source XML element count (e.g.100). - Set the Schema Filter
schemaGroupproperty toJSON. - Set the Elastic Indexing Filter
clusterproperty to point to theElastic Clusterdocument you created earlier. - Set the Write Record Count filter
countReadproperty tofalse.
- Set the Split Filter
Now you have created a template indexing pipeline, it’s time to create a feed-specific pipeline that inherits this template.
Create an Elasticsearch Indexing Pipeline
Procedure
- Right-click on a folder in the Stroom Explorer pane .
- Enter a name for your pipeline and click .
- Click the
Inherit Frombutton. - In the dialog that appears, select the template pipeline you created named
Indexing (Elasticsearch)and click . - Select the Elastic Indexing Filter pipeline element.
- Set the
indexNameproperty to the name of the destination index or data stream.indexNamemay be a simple string (static) or dynamic. - If using dynamic index names, configure the translation to output named element(s) that will be interpolated into
indexNamefor each document indexed.
Choosing between Simple and Dynamic Index Names
Indexing data to a single, named data stream or index, is a simple and convenient way to manage data. There are cases however, where indices may contain significant volumes of data spanning long periods - and where a large portion of indexing will be performed up-front (such as when processing a feed with a lot of historical data). As Elasticsearch data stream indices roll over based on the current time (not event time), it is helpful to be able to partition data streams by user-defined properties such as year. This use case is met by Stroom’s dynamic index naming.
Note
Single Named Index or Data Stream
This is the simplest use case and is suitable where you want to write all data for a particular pipeline, to a single data stream or index.
Whether data is written to an actual index or data stream depends on your index template, specifically whether you have declared data_stream: {}.
If this property exists in the index template matching indexName, a data stream is created when the first document is indexed.
Data streams, amongst many other features, provide the option to use Elasticsearch
Index Lifecycle Management (ILM) policies
to manage their lifecycle.
Note
string field named @timestamp in the output JSON XML.
This is mandatory and indexing will fail if this field isn't a valid date value.
Dynamic Data Stream Names
With a dynamic stream name, indexName contains the names of elements, for example: stroom-events-v1-{year}.
For each document, the final index name is computed based on the values of the corresponding elements within the resulting JSON XML.
For example, if the JSON XML representation of an event consists of the following, the document will be indexed to the index or data stream named stroom-events-v1-2022:
<?xml version="1.1" encoding="UTF-8"?>
<array
xmlns="http://www.w3.org/2005/xpath-functions"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2005/xpath-functions file://xpath-functions.xsd">
<map>
<number key="StreamId">3045516</number>
<number key="EventId">1</number>
<string key="@timestamp">2022-12-16T02:46:29.218Z</string>
<number key="year">2022</number>
</map>
</array>
This is due to the value of /map/number[@key='year'] being 2022.
This approach can be useful when you need to apply different ILM policies, such as maintaining older data on slower storage tiers.
Warning
indexName must exist in the JSON XML (unless it is an empty document).
If a blank value is desired, output an empty string element.
Note
_ (underscore), its value is only used for indexName interpolation, and it is not included in the final JSON.
Other Applications for Dynamic Data Stream Names
Dynamic data stream names can also help in other scenarios, such as implementing fine-grained retention policies, such as deleting documents that aren’t user-attributed after 12 months.
While Stroom ElasticIndex supports data retention expressions, deleting documents in Elasticsearch by query is highly inefficient and doesn’t cause disk space to be freed (this requires an index to be force-merged, an expensive operation).
A better solution therefore, is to use dynamic data stream names to partition data and assign certain partitions to specific ILM policies and/or data tiers.
Migrating Older Data Streams to Other Data Tiers
Say a feed is indexed, spanning data from 2020 through 2023.
Assuming most searches only need to query data from the current year, the data streams stroom-events-v1-2020 and stroom-events-v1-2021 can be moved to cold storage.
To achieve this, use
index-level shard allocation filtering
.
In Kibana Dev Tools, execute the following command:
PUT stroom-events-v1-2020,stroom-events-v1-2021/_settings
{
"index.routing.allocation.include._tier_preference": "data_cold"
}
This example assumes a cold data tier has been defined for the cluster. If the command executes successfully, shards from the specified data streams are gradually migrated to the nodes comprising the destination data tier.
Create an Indexing Translation
In this example, let’s assume you have event data that looks like the following:
<?xml version="1.1" encoding="UTF-8"?>
<Events
xmlns="event-logging:3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="event-logging:3 file://event-logging-v3.5.2.xsd"
Version="3.5.2">
<Event>
<EventTime>
<TimeCreated>2022-12-16T02:46:29.218Z</TimeCreated>
</EventTime>
<EventSource>
<System>
<Name>Nginx</Name>
<Environment>Development</Environment>
</System>
<Generator>Filebeat</Generator>
<Device>
<HostName>localhost</HostName>
</Device>
<User>
<Id>john.smith1</Id>
<Name>John Smith</Name>
<State>active</State>
</User>
</EventSource>
<EventDetail>
<View>
<Resource>
<URL>http://localhost:8080/index.html</URL>
</Resource>
<Data Name="Tags" Value="dev,testing" />
<Data
Name="Message"
Value="TLSv1.2 AES128-SHA 1.1.1.1 "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0"" />
</View>
</EventDetail>
</Event>
<Event>
...
</Event>
</Events>
We need to write an XSL transform (XSLT) to form a JSON document for each stream processed.
Each document must consist of an array element one or more map elements (each representing an Event), each with the necessary properties as per our index template.
See XSLT Conversion for instructions on how to write an XSLT.
The output from your XSLT should match the following:
<?xml version="1.1" encoding="UTF-8"?>
<array
xmlns="http://www.w3.org/2005/xpath-functions"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2005/xpath-functions file://xpath-functions.xsd">
<map>
<number key="StreamId">3045516</number>
<number key="EventId">1</number>
<string key="@timestamp">2022-12-16T02:46:29.218Z</string>
<map key="User">
<string key="Id">john.smith1</string>
<string key="Name">John Smith</string>
<boolean key="Active">true</boolean>
</map>
<array key="Tags">
<string>dev</string>
<string>testing</string>
</array>
<string key="Message">TLSv1.2 AES128-SHA 1.1.1.1 "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0"</string>
</map>
<map>
...
</map>
</array>
Assign the Translation to the Indexing Pipeline
Having created your translation, you need to reference it in your indexing pipeline.
- Open the pipeline you created.
- Select the
Structuretab. - Select the XSLTFilter pipeline element.
- Double-click the
xsltproperty value cell. - Select the XSLT you created and click .
- Click .
Step the Pipeline
At this point, you will want to step the pipeline to ensure there are no errors and that output looks as expected.
Execute the Pipeline
Create a pipeline processor and filter to run the pipeline against one or more feeds. Stroom will distribute processing tasks to enabled nodes and send documents to Elasticsearch for indexing.
You can monitor indexing status via your Elasticsearch monitoring tool of choice.
Detecting and Handling Errors
If any errors occur while a stream is being indexed, an Error stream is created, containing details of each failure.
Error streams can be found under the Data tab of either the indexing pipeline or receiving Feed.
Note
Error streams.
Click then add a condition Type = Error.
Once you have addressed the underlying cause for a particular type of error (such as an incorrect field mapping), reprocess affected streams:
- Select any
Errorstreams relating for reprocessing, by clicking the relevant checkboxes in the stream list (top pane). - Click .
- In the dialog that appears, check
Reprocess dataand click . - Click for any confirmation prompts that follow.
Stroom will re-send data from the selected Event streams to Elasticsearch for indexing.
Any existing documents matching the StreamId of the original Event stream are first deleted automatically to avoid duplication.
Tips and Tricks
Use a Common Schema for Your Indices
An example is Elastic Common Schema (ECS) . This helps users understand the purpose of each field and to build cross-index queries more simply by using a set of common fields (such as a user ID).
With this in mind, it is important that common fields also have the same data type in each index. Component templates help make this easier and reduce the chance of error, by centralising the definition of common fields to a single component.
Use a Version Control System (such as git) to Track Index and Component Templates
This helps keep track of changes over time and can be an important resource for both administrators and users.
Rebuilding an Index
Sometimes it is necessary to rebuild an index. This could be due to a change in field mapping, shard count or responding to a user feature request.
To rebuild an index:
- Drain the indexing pipeline by deactivating any processor filters and waiting for any running tasks to complete.
- Delete the index or data stream via the Elasticsearch API or Kibana.
- Make the required changes to the index template and/or XSL translation.
- Create a new processor filter either from scratch or using the button.
- Activate the new processor filter.
Use a Versioned Index Naming Convention
As with the earlier example stroom-events-v1, a version number is appended to the name of the index or data stream.
If a new field is added, or some other change occurred requiring the index to be rebuilt, users would experience downtime.
This can be avoided by incrementing the version and performing the rebuild against a new index: stroom-events-v2.
Users could continue querying stroom-events-v1 until it is deleted.
This approach involves the following steps:
- Create a new Elasticsearch index template targeting the new index name (in this case,
stroom-events-v2). - Create a copy of the indexing pipeline, targeting the new index in the Elastic Indexing Filter.
- Create and activate a processing filter for the new pipeline.
- Once indexing is complete, update the Elastic Index document to point to
stroom-events-v2. Users will now be searching against the new index. - Drain any tasks for the original indexing pipeline and delete it.
- Delete index
stroom-events-v1using either the Elasticsearch API or Kibana.
If you created a data view in Kibana, you’ll also want to update this to point to the new index / data stream.
2.4 - Exploring Data in Kibana
Kibana is part of the Elastic Stack and provides users with an interactive, visual way to query, visualise and explore data in Elasticsearch.
It is highly customisable and provides users and teams with tools to create and share dashboards, searches, reports and other content.
Once data has been indexed by Stroom into Elasticsearch, it can be explored in Kibana. You will first need to create a data view in order to query your indices.
Why Use Kibana?
There are several use cases that benefit from Kibana:
- Convenient and powerful drag-and-drop charts and other visualisation types using Kibana Lens. Much more performant and easier to customise than built-in Stroom dashboard visualisations.
- Field statistics and value summaries with Kibana Discover. Great for doing initial audit data survey.
- Geospatial analysis and visualisation.
- Search field auto-completion.
- Runtime fields . Good for data exploration, at the cost of performance.
3 - Lucene Indexes
Stroom uses
Apache Lucene
for its built-in indexing solution.
Index documents are stored in a
Volume
Volume
TODO
Shards and Volumes
The documents of an index are held in index shards.
Each shard is a directory of files in one of the index volumes of the
Volume group
Volume group
An index volume is either local to one node or shared by all nodes. A shard on a local volume can only be searched and written to by its own node. A shard on a shared volume can be searched and written to by any node, so a search does not depend on the node that wrote the shard being up. See Shared Index Volumes.
If indexing fails part way through a stream, the documents of the stream are removed from the index and the stream is indexed again. See Re-Indexed Streams.
Field Configuration
Field Types
Id- Treated as aLong.Boolean- True/False values.Integer- Whole numbers from -2,147,483,648 to 2,147,483,647.Long- Whole numbers from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.Float- Fractional numbers. Sufficient for storing 6 to 7 decimal digits.Double- Fractional numbers. Sufficient for storing 15 decimal digits.Date- Date and time values.Text- Text data.Number- An alias forLong.
Stored Fields
If a field is Stored then it means the complete field value will be stored in the index. This means the value can be retrieved from the index when building search results rather than using the slower Search Extraction process. Storing field values comes at the cost of high storage requirements for the index. If storage space is not an issue then storing all fields that you want to return in search results is the optimum.
Indexed Fields
An Indexed field is one that will be processed by Lucene so that the field can be queried. How the field is indexed will depend on the Field type and the Analyser used.
If you have fields that you do not want to be able to filter (i.e. that you won’t use as a query term) then you can include them as non-Indexed fields.
Including a non-indexed field means it will be available for the user to select in the
Dashboard
Dashboard
Positions
If Positions is selected then Lucene will store the positions of all the field terms in the document.
Analyser Types
The Analyser determines how Lucene reads the fields value and extracts tokens from it. The choice of Analyser will depend on the data in the field and how you want to search it.
Keyword- Treats the whole field value as one token. Useful for things like IDs and post codes. Supports the Case Sensitivity setting.Alpha- Tokenises on any non-letter characters, e.g.one1 two2 three 3=>onetwothree. Strips non-letter characters. Supports the Case Sensitivity setting.Numeric-Alpha numeric- Tokenises on any non-letter/digit characters, e.g.one1 two2 three 3=>one1two2three3. Supports the Case Sensitivity setting.Whitespace- Tokenises only on white space. Not affected by the Case Sensitivity setting, case sensitive.Stop words- Tokenises based on non-letter characters and removes Stop Words, e.g.and. Not affected by the Case Sensitivity setting. Case insensitive.Standard- The most common analyser. Tokenises the value on spaces and punctuation but recognises URLs and email addresses. Removes Stop Words, e.g.and. Not affected by the Case Sensitivity setting. Case insensitive. e.g.Find Stroom at github.com/stroom=>FindStroomatgithub.com/stroom.
Stop Words
Some of the Analysers use a set of stop words for the tokenisers. This is the list of stop words that will not be indexed.
a, an, and, are, as, at, be, but, by, for, if, in, into, is, it, no, not, of, on, or, such, that, the, their, then, there, these, they, this, to, was, will, with
Case Sensitivity
Some of the Analyser types support case (in)sensitivity.
For example if the Analyser supports it the value TWO two would either be tokenised as TWO two or two two.