How To Compare `GitLab` and `Gerrit` Side-By-Side
loganknecht opened this issue ยท 6 comments
Question
Hello!
I've found the schema definitions here:
- Gerrit
- GitLab
And in the Gerrit
configurations it states
changeset_author_name - Changeset author name, equal to owner_name
However in the GitLab
schema there is no changeset_author_name
or owner_name
I was hoping to create a unified dashboard based on the Author Name
in order to compare Merge Requests
in GitLab
and Change Sets
in Gerrit
I have created an index pattern that lets me search both the enriched
Gerrit
and GitLab
indicies, but I'm not sure how to filter the returned data with respect to the same User
Is there anyway to filter the data such that I can get the data from both indices with respect to Change Sets
and Merge Requests
and then be able to build a dashboard off of that information?
Hi @loganknecht
There is no changeset_author_name
in GitLab due to GitLab did not use that field name.
At first glance, you can:
- Create a scripted field. In GitLab or/and Gerrit index pattern
1.1 In GitLab index pattern: Createchangeset_author_name
and copy themerge_author_name
value
1.2 In Gerrit index pattern: Createmerge_author_name
and copy thechangeset_author_name
value
This way you can have changeset_author_name
or/and merge_author_name
fields on both index patterns.
I hope it helps you.
@zhquan Thank you so much for the advice.
I believe I've found a solution that works moving forward.
I would like to leave this open until I post my follow-up explaining how I solved this issue.
Hello!
For anyone who wants to connect two different enriched
indices and search across them using a unified field, here is how you can do that.
Create an Index Pattern
- Go to the menu on the left
- Go to
Stack Management
- Go to
Index Patterns
- Create new index pattern for
enriched
indices
The index pattern is a tool to group multiple different indices together so they can be queried at the same time. A helpful analogy is to think of it like an SQL join, but using the index name to determine how to group them together.
Grouping indices by name (AKA Index Patterns) can be problematic if you don't have a good naming convention. So make sure to plan correctly for information you need to query across.
Configuring Scripted Fields
Scripted fields are needed to normalize the search filtering so that you only have to use a single field to search for a user across different indices.
- Go to the menu on the left
- Go to
Stack Management
- Go to
Index Patterns
- Select the
*_enriched
index pattern you created above - Select the
scripted fields
tab - Create a new scripted field following the steps below
sf-author_name
- Name:
sf-author_name
- Language:
painless
- Type:
string
- Transform: N/A
- Popularity: N/A
// Gerrit Review Enriched Index
if (
doc.containsKey("changeset_author_name") &&
!doc["changeset_author_name"].empty &&
doc["changeset_author_name"].value != ""
) {
return doc["changeset_author_name"].value;
}
// GitLab Merge Request Enriched Index
else if (
doc.containsKey("merge_author_name") &&
!doc["merge_author_name"].empty &&
doc["merge_author_name"].value != ""
) {
return doc["merge_author_name"].value;
}
// GitLab Merge Request Enriched Index
else if (doc.containsKey("author_name") && !doc["author_name"].empty && doc["author_name"].value != "") {
return doc["author_name"].value;
}
// Fall Through
else {
return "Unknown - " + doc["_index"];
}
sf-author_username
- Name:
sf-author_username
- Language:
painless
- Type:
string
- Transform: N/A
- Popularity: N/A
// Gerrit Review Enriched Index
if (
doc.containsKey("changeset_author_user_name") &&
!doc["changeset_author_user_name"].empty &&
doc["changeset_author_user_name"].value != ""
) {
return doc["changeset_author_user_name"].value;
}
// GitLab Merge Request Enriched Index
else if (doc.containsKey("author_user_name") && !doc["author_user_name"].empty && doc["author_user_name"].value != "") {
return doc["author_user_name"].value;
}
// GitLab Merge Request Enriched Index
else if (doc.containsKey("author_username") && !doc["author_username"].empty && doc["author_username"].value != "") {
return doc["author_username"].value;
}
// Fall Through
else {
return "Unknown - " + doc["_index"];
}
Then all you have to do is create a dashboard panel
that uses the *enriched
index pattern as the basis for its queries and you can filter by sf-author_username
and sf-author_name
This won't be perfect, and you might need to update the fields being used to collapse the data into a single scripted field, but this does work, and it seems robust enough.
Closing as done, with examples provided.
Thanks @loganknecht . Very useful!
No problem @sduenas
And as always - thank you everyone for your hard work on this amazing tool. I really appreciate what you've done here!