Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Changing index names to remove leading dot #151

Merged
merged 2 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions documentation/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ curl -X PUT "http://localhost:9200/_plugins/ubi/awesome?index=ecommerce&id_field
Send an event to the `awesome` store:

```
curl -X POST http://localhost:9200/_plugins/ubi/mystore -H "Content-Type: application/json" -d '
curl -X POST http://localhost:9200/_plugins/ubi/awesome -H "Content-Type: application/json" -d '
{
"action_name": "search",
"user_id": "98fcf189-4fa8-4322-b6f5-63fbb6b556c9",
Expand All @@ -44,7 +44,7 @@ curl -X POST http://localhost:9200/_plugins/ubi/mystore -H "Content-Type: applic
Get events:

```
curl -s http://localhost:9200/.awesome_events/_search | jq
curl -s http://localhost:9200/ubi_awesome_events/_search | jq
```

Do a search of the `ecommerce` index:
Expand All @@ -56,7 +56,7 @@ curl -s http://localhost:9200/ecommerce/_search -H "X-ubi-store: awesome" | jq
Get queries:

```
curl -s http://localhost:9200/.awesome_queries/_search | jq
curl -s http://localhost:9200/ubi_awesome_queries/_search | jq
```

Delete the store:
Expand Down Expand Up @@ -130,7 +130,7 @@ The plugin exposes a REST API for managing UBI stores and persisting events.

### Creating a UBI Store

To create a UBI store to contain events and queries, send a `PUT` request:
To create a UBI store to contain events and queries, send a `PUT` request. The following request creates a store called `mystore`.

```
curl -X PUT http://localhost:9200/_plugins/ubi/mystore?index=ecommerce
Expand Down
2 changes: 1 addition & 1 deletion documentation/queries/dsl_queries.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@


```json
GET .ubi_log_events/_search
GET ubi_log_events/_search
{
"size":0,
"aggs":{
Expand Down
16 changes: 8 additions & 8 deletions documentation/queries/sql_queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ order by user_id
```sql
select
count(0)
from .ubi_log_events
from ubi_log_events
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RasonJ I think you had the name of the store being ubi_log. I did not change these to ubi_ubi_log_events just for clarity. So just a note about that.

where action_name='on_search' and event_attributes.data.data_detail.query_data.query_response_hit_ids is null
order by timestamp
```
Expand All @@ -30,7 +30,7 @@ Both client and server-side queries should return the same number.
```sql
select
message, count(0) Total
from .ubi_log_events
from ubi_log_events
where
action_name='on_search'
group by message
Expand Down Expand Up @@ -66,7 +66,7 @@ To make a pie chart like widget on all the most common events:
```sql
select
action_name, count(0) Total
from .ubi_log_events
from ubi_log_events
group by action_name
order by Total desc
```
Expand All @@ -88,7 +88,7 @@ To make a pie chart like widget on the most common events preceded by a query:
```sql
select
action_name, count(0) Total
from .ubi_log_events
from ubi_log_events
where query_id is not null
group by action_name
order by Total desc
Expand Down Expand Up @@ -122,7 +122,7 @@ Search for the events that correspond to the query above, `1065c70f-d46a-442f-8c
```sql
select
query_id, action_name, message_type, message, event_attributes.data.data_id, event_attributes.data.description, session_id, user_id
from .ubi_log_events
from ubi_log_events
where query_id = '1065c70f-d46a-442f-8ce4-0b5e7a71a892'
order by timestamp
```
Expand All @@ -147,7 +147,7 @@ To look at more sessions from the same user above, `155_7e3471ff-14c8-45cb-bc49-
```sql
select
user_id, session_id, query_id, action_name, message_type, message, event_attributes.data.data_type, timestamp
from .ubi_log_events
from ubi_log_events
where user_id ='155_7e3471ff-14c8-45cb-bc49-83a056c37192'
order by timestamp
```
Expand Down Expand Up @@ -250,7 +250,7 @@ user_id|session_id|query_id|action_name|message_type|message|event_attributes.da
```sql
select
user_id, session_id, count(0) EventTotal
from .ubi_log_events
from ubi_log_events
where action_name='logout' and query_id is null
group by user_id, session_id
order by EventTotal desc
Expand Down Expand Up @@ -281,7 +281,7 @@ Since some of these query-less logouts repeat with some users, here is a query t
```sql
select
user_id, count(0) EventTotal
from .ubi_log_events
from ubi_log_events
where action_name='logout' and query_id is null
group by user_id
order by EventTotal desc
Expand Down
4 changes: 2 additions & 2 deletions load-test/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ locust -f load-test.py --headless -u 50 -r 10 --run-time 300s --host http://loca
sleep 30

# Get count of indexed events.
EVENTS=`curl -s http://localhost:9200/.mystore_events/_count | jq .count`
EVENTS=`curl -s http://localhost:9200/ubi_mystore_events/_count | jq .count`
echo "Found $EVENTS events"

# Get count of indexed queries.
QUERIES=`curl -s http://localhost:9200/.mystore_queries/_count | jq .count`
QUERIES=`curl -s http://localhost:9200/ubi_mystore_queries/_count | jq .count`
echo "Found $QUERIES queries"
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,7 @@ private RestChannelConsumer get(final NodeClient nodeClient) {
@Override
public void processResponse(final GetIndexResponse getIndexResponse) throws Exception {

final Set<String> stores = new HashSet<>();

for(final String index : getIndexResponse.indices()) {
if(index.startsWith(".") && index.endsWith("_events")) {
stores.add(index.substring(1, index.length() - 7));
}
}
final Set<String> stores = getStoreNames(getIndexResponse.indices());

final XContentBuilder builder = XContentType.JSON.contentBuilder();
builder.startObject().field("stores", stores);
Expand Down Expand Up @@ -304,8 +298,8 @@ private String setEventTimestamp(final String eventJson) throws JsonProcessingEx
private Set<String> getStoreNames(String[] indices) {
final Set<String> stores = new HashSet<>();
for (final String index : indices) {
if (index.startsWith(".") && index.endsWith("_events")) {
stores.add(index.substring(1, index.length() - 7));
if (index.startsWith("ubi_") && index.endsWith("_events")) {
stores.add(index.substring(4, index.length() - 7));
}
}
return stores;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/o19s/ubi/utils/UbiUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private UbiUtils() {
* @return The formatted name of the queries index.
*/
public static String getQueriesIndexName(final String storeName) {
return "." + storeName + "_queries";
return "ubi_" + storeName + "_queries";
}

/**
Expand All @@ -42,7 +42,7 @@ public static String getQueriesIndexName(final String storeName) {
* @return The formatted name of the events index.
*/
public static String getEventsIndexName(final String storeName) {
return "." + storeName + "_events";
return "ubi_" + storeName + "_events";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@

- do:
cluster.health:
index: [.mystore_events, .mystore_queries]
index: [ubi_mystore_events, ubi_mystore_queries]
wait_for_no_initializing_shards: true

- do:
indices.exists:
index: .mystore_events
index: ubi_mystore_events

- is_true: ''

- do:
indices.exists:
index: .mystore_queries
index: ubi_mystore_queries

- is_true: ''

Expand All @@ -39,13 +39,13 @@

- do:
indices.exists:
index: .mystore_events
index: ubi_mystore_events

- is_false: ''

- do:
indices.exists:
index: .mystore_queries
index: ubi_mystore_queries

- is_false: ''

Expand Down Expand Up @@ -90,7 +90,7 @@

- do:
cluster.health:
index: [.mystore_events, .mystore_queries]
index: [ubi_mystore_events, ubi_mystore_queries]
wait_for_no_initializing_shards: true

- do:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ setup:

- do:
cluster.health:
index: [.mystore_events, .mystore_queries]
index: [ubi_mystore_events, ubi_mystore_queries]
wait_for_no_initializing_shards: true

- do:
indices.exists:
index: .mystore_events
index: ubi_mystore_events

- is_true: ''

- do:
indices.exists:
index: .mystore_queries
index: ubi_mystore_queries

- is_true: ''

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ setup:

- do:
cluster.health:
index: [.mystore2_events, .mystore2_queries]
index: [ubi_mystore2_events, ubi_mystore2_queries]
wait_for_no_initializing_shards: true

# With an empty timestamp
Expand Down
Loading