-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add DataStream to ElasticsearchOperationFactory * Add DataStreamItem - batch item * Add DataStreamBatchRequest - batch * Add ElasticsearchDataStreamAPI - builders and serializers * Add ElasticsearchDataStreamAPIPlugin - Log4j2 config
- Loading branch information
Showing
39 changed files
with
2,734 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
log4j2-elasticsearch-core/src/main/java/org/appenders/log4j2/elasticsearch/DataStream.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package org.appenders.log4j2.elasticsearch; | ||
|
||
/*- | ||
* #%L | ||
* log4j2-elasticsearch | ||
* %% | ||
* Copyright (C) 2022 Rafal Foltynski | ||
* %% | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* #L% | ||
*/ | ||
|
||
public class DataStream implements OpSource { | ||
|
||
public static final String TYPE_NAME = "DataStream"; | ||
private static final String EMPTY_SOURCE = ""; | ||
|
||
private final String name; | ||
|
||
/** | ||
* @param name Data stream name | ||
*/ | ||
public DataStream(final String name) { | ||
this.name = name; | ||
} | ||
|
||
/** | ||
* @return Data stream name | ||
*/ | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
/** | ||
* @return {@link #TYPE_NAME} | ||
*/ | ||
@Override | ||
public String getType() { | ||
return TYPE_NAME; | ||
} | ||
|
||
/** | ||
* @return Empty String {@code ""} | ||
*/ | ||
@Override | ||
public String getSource() { | ||
return EMPTY_SOURCE; | ||
} | ||
|
||
public static class Builder { | ||
|
||
protected String name; | ||
|
||
public DataStream build() { | ||
validate(); | ||
return new DataStream(name); | ||
} | ||
|
||
void validate() { | ||
|
||
if (name == null) { | ||
throw new IllegalArgumentException("No name provided for " + DataStream.class.getSimpleName()); | ||
} | ||
|
||
} | ||
|
||
/** | ||
* @param name Data stream name | ||
* @return this | ||
*/ | ||
public Builder withName(String name) { | ||
this.name = name; | ||
return this; | ||
} | ||
|
||
} | ||
|
||
} |
69 changes: 69 additions & 0 deletions
69
...elasticsearch-core/src/main/java/org/appenders/log4j2/elasticsearch/DataStreamPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package org.appenders.log4j2.elasticsearch; | ||
|
||
/*- | ||
* #%L | ||
* log4j2-elasticsearch | ||
* %% | ||
* Copyright (C) 2022 Rafal Foltynski | ||
* %% | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* #L% | ||
*/ | ||
|
||
import org.apache.logging.log4j.core.config.ConfigurationException; | ||
import org.apache.logging.log4j.core.config.Node; | ||
import org.apache.logging.log4j.core.config.plugins.Plugin; | ||
import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute; | ||
import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory; | ||
|
||
|
||
@Plugin(name = DataStreamPlugin.PLUGIN_NAME, category = Node.CATEGORY, elementType = "setupOperation", printObject = true) | ||
public class DataStreamPlugin extends DataStream { | ||
|
||
public static final String PLUGIN_NAME = "DataStream"; | ||
|
||
/** | ||
* @param name Data stream name | ||
*/ | ||
protected DataStreamPlugin(final String name) { | ||
super(name); | ||
} | ||
|
||
@PluginBuilderFactory | ||
public static DataStreamPlugin.Builder newBuilder() { | ||
return new Builder(); | ||
} | ||
|
||
public static class Builder implements org.apache.logging.log4j.core.util.Builder<DataStreamPlugin> { | ||
|
||
@PluginBuilderAttribute | ||
private String name; | ||
|
||
@Override | ||
public DataStreamPlugin build() { | ||
|
||
if (name == null) { | ||
throw new ConfigurationException("No name provided for " + PLUGIN_NAME); | ||
} | ||
|
||
return new DataStreamPlugin(name); | ||
} | ||
|
||
public Builder withName(String name) { | ||
this.name = name; | ||
return this; | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...rc/main/java/org/appenders/log4j2/elasticsearch/json/jackson/LogEventDataStreamMixIn.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.appenders.log4j2.elasticsearch.json.jackson; | ||
|
||
/*- | ||
* #%L | ||
* log4j2-elasticsearch | ||
* %% | ||
* Copyright (C) 2022 Rafal Foltynski | ||
* %% | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* #L% | ||
*/ | ||
|
||
public abstract class LogEventDataStreamMixIn extends ExtendedLogEventJacksonJsonMixIn implements LogEventTimestampMixIn { | ||
|
||
} | ||
|
30 changes: 30 additions & 0 deletions
30
...src/main/java/org/appenders/log4j2/elasticsearch/json/jackson/LogEventTimestampMixIn.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.appenders.log4j2.elasticsearch.json.jackson; | ||
|
||
/*- | ||
* #%L | ||
* log4j2-elasticsearch | ||
* %% | ||
* Copyright (C) 2022 Rafal Foltynski | ||
* %% | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* #L% | ||
*/ | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
public interface LogEventTimestampMixIn { | ||
|
||
@JsonProperty("@timestamp") | ||
long getTimeMillis(); | ||
|
||
} |
Oops, something went wrong.