Skip to content

Commit

Permalink
host base&NoScroll logs filtering per index
Browse files Browse the repository at this point in the history
  • Loading branch information
voxparcxls committed Jun 11, 2024
1 parent a2f82ff commit e2f2af1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
12 changes: 5 additions & 7 deletions cws-service/src/main/java/jpl/cws/controller/RestService.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public class RestService extends MvcCore {

@Value("${cws.elasticsearch.protocol}") private String elasticsearchProtocolName;
@Value("${cws.elasticsearch.hostname}") private String elasticsearchHostname;
@Value("${cws.elasticsearch.index.prefix}") private String elasticsearchIndexPrefix;
@Value("${cws.elasticsearch.port}") private String elasticsearchPort;

@Value("${cws.elasticsearch.use.auth}") private String elasticsearchUseAuth;
Expand Down Expand Up @@ -769,8 +770,7 @@ public ModelAndView validateAndSaveSnippets(
@ApiOperation(value = "Gets the total number of log rows.", tags = {"Logs"}, produces = "application/json")
@RequestMapping(value="/logs/get/count", method = GET, produces="application/json")
public @ResponseBody String getNumLogs() {
String urlString = constructElasticsearchUrl("/_count");

String urlString = constructElasticsearchUrl("/" + elasticsearchIndexPrefix + "-logstash-*/_count");
log.trace("REST getNumLogs query = " + urlString);

try {
Expand Down Expand Up @@ -804,8 +804,7 @@ public ModelAndView validateAndSaveSnippets(
@RequestMapping(value = "/logs/get/noScroll", method = GET, produces="application/json")
public @ResponseBody String getLogsNoScroll(
@RequestParam(value = "source") String source) {
String urlString = constructElasticsearchUrl("/_search");

String urlString = constructElasticsearchUrl("/" + elasticsearchIndexPrefix + "-logstash-*/_search");
log.debug("REST logs/get/noScroll query = " + urlString);

try {
Expand Down Expand Up @@ -843,8 +842,7 @@ public ModelAndView validateAndSaveSnippets(
@RequestMapping(value = "/logs/get", method = GET, produces="application/json")
public @ResponseBody String getLogs(
@RequestParam(value = "source") String source) {
String urlString = constructElasticsearchUrl("/_search?scroll=5m&source=" + source + "&source_content_type=application/json");

String urlString = constructElasticsearchUrl("/" + elasticsearchIndexPrefix + "-logstash-*/_search?scroll=5m&source=" + source + "&source_content_type=application/json");
log.trace("REST getLogs query = " + urlString);

try {
Expand Down Expand Up @@ -881,7 +879,7 @@ public ModelAndView validateAndSaveSnippets(
HttpServletResponse response,
@PathVariable String procDefKey
) {
String urlString = constructElasticsearchUrl("/*/_delete_by_query");
String urlString = constructElasticsearchUrl("/" + elasticsearchIndexPrefix + "-logstash*/_delete_by_query");
log.debug("REST deleteLogsByProcDefKey url = " + urlString);

String data = "{ \"query\": { \"bool\": { \"must\": [ { \"match\": { \"procDefKey\": \"" + procDefKey + "\" } } ] } } }";
Expand Down
2 changes: 1 addition & 1 deletion install/cws-ui/configuration.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
for (var i = 0; i < data.length; i++) {
var index = data[i];
if (index.index.startsWith("${esIndexPrefix}")) {
if (index.index.startsWith("${esIndexPrefix}" + "-logstash")) {
var health = index.health;
Expand Down
1 change: 1 addition & 0 deletions install/example-cws-configuration.properties
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ cws_notification_emails=[AdminEmailAddresses(comma separated)]
# elasticsearch_protocol=HTTPS
elasticsearch_protocol=[YourElasticsearchProtocol]
elasticsearch_host=[YourElasticsearchHost]
elasticsearch_index_prefix=[YourElasticsearchIndexPrefix]
elasticsearch_port=9200
elasticsearch_use_auth=n
elasticsearch_username=[YourElasticsearchUsername]
Expand Down

0 comments on commit e2f2af1

Please sign in to comment.