Skip to content

Commit

Permalink
add component path analyzer to allow searching for components by name…
Browse files Browse the repository at this point in the history
… in messages and extra info
  • Loading branch information
jclausen committed Sep 25, 2024
1 parent 8abe6c2 commit 413f291
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

* Add component path analyzer to message and extra info fields so that parts of component paths are searchable
* Add `labels` property to Logstash Appender properties to allow for custom labels
* Add `labels` convention to Logstash Appender UserInfo UDF to allow keyword label filtering
* Add `AppenderService` object which allows for easier creation of detached appenders and index-specific logging
Expand Down
28 changes: 26 additions & 2 deletions models/logging/LogstashAppender.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,25 @@ component
"number_of_shards" : getProperty( "indexShards" ),
"number_of_replicas" : getProperty( "indexReplicas" ),
"index.lifecycle.name" : getProperty( "ILMPolicyName" ),
"index.default_pipeline" : getProperty( "pipelineName" )
"index.default_pipeline" : getProperty( "pipelineName" ),
"analysis": {
"analyzer": {
"component_path_analyzer": {
"tokenizer": "standard",
"filter": [ "component_path_filter" ]
}
},
"filter": {
"component_path_filter": {
"type": "word_delimiter",
"type_table": [ ". => SUBWORD_DELIM" ],
"split_on_case_change": false,
"split_on_numerics": false,
"stem_english_possessive": true,
"preserve_original": true
}
}
}
},
"mappings" : {
"dynamic_templates" : [
Expand Down Expand Up @@ -701,10 +719,16 @@ component
},
"error" : {
"type" : "object",
"properties" : { "extrainfo" : { "type" : "text" } }
"properties" : {
"extrainfo" : {
"type" : "text",
"analyzer": "component_path_analyzer",
}
}
},
"message" : {
"type" : "text",
"analyzer": "component_path_analyzer",
"fields" : { "keyword" : { "type" : "keyword", "ignore_above" : 512 } }
},
"event" : {
Expand Down
39 changes: 37 additions & 2 deletions test-harness/tests/specs/unit/LogstashAppenderTest.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ component extends="coldbox.system.testing.BaseTestCase" {
"LogstashAppenderTest",
{
"applicationName" : "testspecs",
"dataStream" : "testing-data-stream",
"dataStreamPattern" : "testing-data-stream",
"dataStream" : "logs-testing-data-stream",
"dataStreamPattern" : "logs-testing-data-stream*",
"componentTemplateName" : "testing-data-mappings",
"indexTemplateName" : "logstash-appender-testing",
"ILMPolicyName" : "logstash-appender-test-policy",
Expand Down Expand Up @@ -129,6 +129,41 @@ component extends="coldbox.system.testing.BaseTestCase" {

} );

it( "Tests the component path filter template", function(){
testLoge = getMockBox().createMock( className = "coldbox.system.logging.LogEvent" );

testLoge.init(
message = "Many.Dots.In.Snuffalupagus.Log",
severity = 4,
extraInfo = {
"friend" : "Big Bird",
"program" : "Sesame Street"
},
category = "SesameLogs"
);

variables.model.logMessage( testLoge );
sleep( 5000 );

var documents = getWirebox()
.getInstance( "SearchBuilder@cbelasticsearch" )
.new( variables.model.getProperty( "dataStreamPattern" ) )
.setQuery( {
"bool" : {
"must" : [
{ "match" : { "message" : "Snuffalupagus" } }
]
}
} )
.execute()
.getHits();

expect( documents.len() ).toBeGT( 0 );

debug( documents.first().getDocument() );

} );

it( "Tests logMessage() with java stack trace", function(){
// create an error message
try {
Expand Down

0 comments on commit 413f291

Please sign in to comment.