Skip to content
This repository was archived by the owner on Jan 6, 2023. It is now read-only.

Commit 66a71c8

Browse files
authored
Initial upload of the project
0 parents  commit 66a71c8

File tree

20 files changed

+1591
-0
lines changed

20 files changed

+1591
-0
lines changed

CONTRIBUTING.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
3+
---
4+
5+
# Source Code Submissions
6+
We welcome your contributions and look forward to collaborating with you. We can only accept source code repository
7+
submissions from users who have signed and returned the Oracle
8+
Contributor Agreement. You will find details and the agreement to sign at this OTN web page:
9+
[Oracle Contributor Agreement](http://www.oracle.com/technetwork/community/oca-486395.html).
10+
11+
# Other Contributions
12+
For all project Submissions other than source code repository contributions, the following also applies: Oracle does
13+
not claim ownership of Your Submissions. However, in order to fulfill
14+
the purposes of this project, You must give Oracle and all Users
15+
the right to post, access, discuss, use, publish, disseminate, and refine
16+
Your Submissions.
17+
18+
In legalese: *You hereby grant to Oracle and all
19+
Users a royalty-free, perpetual, irrevocable, worldwide, non-exclusive,
20+
and fully sub-licensable right and license, under Your intellectual
21+
property rights, to reproduce, modify, adapt, publish, translate, create
22+
derivative works from, distribute, perform, display, and use Your
23+
Submissions (in whole or part) and to incorporate or implement them in
24+
other works in any form, media, or technology now known or later
25+
developed, all subject to the obligation to retain any copyright notices
26+
included in Your Submissions. All Users, Oracle, and their
27+
sublicensees are responsible for any modifications they make to the
28+
Submissions of others.*
29+
30+
Copyright © 2017 Oracle and/or its affiliates. All rights reserved.

LICENSE.txt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Copyright (c) 2018 Oracle Corporation,
2+
3+
The Universal Permissive License (UPL), Version 1.0
4+
5+
Subject to the condition set forth below, permission is hereby granted to any person obtaining
6+
a copy of this software, associated documentation and/or data (collectively the "Software"),
7+
free of charge and under any and all copyright rights in the Software, and any and all patent
8+
rights owned or freely licensable by each licensor hereunder covering either (i) the unmodified
9+
Software as contributed to or provided by such licensor, or (ii) the Larger Works
10+
(as defined below), to deal in both
11+
12+
(a) the Software, and
13+
14+
(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if one is included with
15+
the Software (each a "Larger Work" to which the Software is contributed by such licensors), without
16+
restriction, including without limitation the rights to copy, create derivative works of, display,
17+
perform, and distribute the Software and make, use, sell, offer for sale, import, export, have made,
18+
and have sold the Software and the Larger Work(s), and to sublicense the foregoing rights on either
19+
these or other terms.
20+
21+
This license is subject to the following condition:
22+
23+
The above copyright notice and either this complete permission notice or at a minimum a reference to
24+
the UPL must be included in all copies or substantial portions of the Software.
25+
26+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
27+
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
28+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
29+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
30+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31+

README.md

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# Weblogic Logging Exporter
2+
3+
An exporter that adds a log event handler to the weblogic server, such that WLS server Logs can be integrated to [Elastic Stack](https://www.elastic.co/products) in Kubernetes directly, by using the REST API in [Elasticsearch](https://www.elastic.co/products/elasticsearch).
4+
5+
The blog [Let WebLogic work with Elastic Stack in Kubernetes](https://blogs.oracle.com/weblogicserver/let-weblogic-work-with-elk-in-kubernetes) outlines steps that can be used to harvest WLS server logs using Logstash so that they can be filtered, manipulated, and viewed using Elasticsearch and Kibana.
6+
However, that approach requires the setup of a shared volume which is outside of the pod, and the logs needs to be written out to an intermediate log file for harvesting and parsing.
7+
8+
The goal of this project is to provide an easy to configure, robust and production ready solution to access WLS log information through Elasticsearch and Kibana.
9+
10+
## Getting Started
11+
12+
These instructions outlines the steps to build the _weblogic-logging-exporter.jar_ , which can then be integrated to the [Weblogic Kubernetes Operator](https://github.com/oracle/weblogic-kubernetes-operator/) for handling the Server logs generated by the Weblogic Server Domain.
13+
14+
### Prerequisites
15+
16+
Weblogic Logging Exporter depends on the Weblogic Logging Jar which is available from the [ Oracle Maven Repository](http://maven.oracle.com/).
17+
18+
To access the Oracle Maven Repository, there are two fundamental requirements to be aware of:
19+
20+
1. You must be using [Maven 3.2.5](http://maven.apache.org/docs/3.2.5/release-notes.html) or later. This contains the version of the component [Wagon 2.8](http://maven.apache.org/wagon/) that has been enhanced to support access to artifacts that are protected by [HTTP authentication schemes](https://issues.apache.org/jira/projects/WAGON/issues/WAGON-422).
21+
22+
2. You must be registered with OTN and have accepted the agreement to access and use the Oracle Maven Repository. This can be done with either a new or an existing OTN user account by accessing the http://maven.oracle.com site and clicking the registration link.
23+
Once registered, you then just need to configure your local Maven environment with the details of the Oracle Maven Repository, including information that relates to the authentication model specifying your OTN username and password.
24+
25+
### Building
26+
#### Configure Maven
27+
28+
**1. Encrypt your OTN Password**
29+
30+
You need to configure Maven to use the Oracle Maven Repository. This involves telling Maven about the repository and providing the necessary information to authenticate to the repository.
31+
The following steps shows you how to save your OTN password in your _settings.xml_ file so that you do not have to specify them manually every time.
32+
Oracle recommends that you encrypt your password, using the utilities provided with Maven.
33+
34+
Here is the steps to encrypt your password and save that in your settings. Refer to [Maven Password Encryption](http://maven.apache.org/guides/mini/guide-encryption.html) for more information.
35+
36+
```
37+
mvn --encrypt-master-password my_master_password
38+
39+
```
40+
The output will be a string similar to this:
41+
42+
_{abcdefghijklmnopqrstuvwxyz123=}_
43+
44+
Save this value in your Maven _settings-security.xml_ file
45+
46+
A copy of your _~/.m2/settings-security.xml_ will look like this
47+
```
48+
<settingsSecurity>
49+
<master>{abcdefghijklmnopqrstuvwxyz123=}</master>
50+
</settingsSecurity>
51+
```
52+
53+
Now that you have a master password defined, you can encrypt your OTN password using the following command:
54+
```
55+
mvn --encrypt-password my_OTN_password
56+
```
57+
The output will be another string that looks like this:
58+
59+
_{==thisIs12My34_OTN_45_encrypted==}_
60+
61+
This will be the password that you provide in the _server_ section of your _settings.xml_ file when you configure the HTTP Wagon.
62+
63+
**2. Adding the Oracle Maven Repository to Your settings.xml**
64+
65+
Add a repository definition to your Maven settings.xml file. The repository definition should look like the following:
66+
67+
```
68+
<profiles>
69+
<profile>
70+
<id>main</id>
71+
<activation>
72+
<activeByDefault>true</activeByDefault>
73+
</activation>
74+
<repositories>
75+
<repository>
76+
<id>maven.oracle.com</id>
77+
<url>https://maven.oracle.com</url>
78+
<layout>default</layout>
79+
<releases>
80+
<enabled>true</enabled>
81+
</releases>
82+
</repository>
83+
</repositories>
84+
85+
<pluginRepositories>
86+
<pluginRepository>
87+
<id>maven.oracle.com</id>
88+
<url>https://maven.oracle.com</url>
89+
</pluginRepository>
90+
</pluginRepositories>
91+
</profile>
92+
</profiles>
93+
```
94+
95+
The Maven settings.xml requires additional settings to support the Oracle Maven Repository.
96+
Add the following _<server>_ element to the _<servers>_ section of the Maven settings.xml to configure the HTTP Wagon.
97+
```
98+
<servers>
99+
<server>
100+
<username>my_OTN_user_name</username>
101+
<password>{==thisIs12My34_OTN_45_encrypted==}</password>
102+
<configuration>
103+
<basicAuthScope>
104+
<host>ANY</host>
105+
<port>ANY</port>
106+
<realm>OAM 11g</realm>
107+
</basicAuthScope>
108+
<httpConfiguration>
109+
<all>
110+
<params>
111+
<property>
112+
<name>http.protocol.allow-circular-redirects</name>
113+
<value>%b,true</value>
114+
</property>
115+
</params>
116+
</all>
117+
</httpConfiguration>
118+
</configuration>
119+
<id>maven.oracle.com</id>
120+
</server>
121+
</servers>
122+
```
123+
124+
If needed, you will need to specify the _proxies_ that is required.
125+
126+
**3. Clone the project and build**
127+
```
128+
git clone git@orahub.oraclecorp.com:derek.sharpe/wls-logging-exporter.git
129+
mvn install
130+
```
131+
132+
The _weblogic-logging-exporter-1.0-SNAPSHOT.jar_ should be available under _target_ directory
133+
134+
## Deployment
135+
136+
TBD. Update on how to integrate this jar to weblogic kubernetes operator.
137+
138+
## Contributing
139+
140+
Please read [CONTRIBUTING.md](https://gist.github.com/PurpleBooth/b24679402957c63ec426) for details on our code of conduct, and the process for submitting pull requests to us.
141+
142+
143+
## License
144+
145+
This project is licensed under the [_Oracle Universal Permissive License, Version 1.0_](http://oss.oracle.com/licenses/upl)

TEST/META-INF/MANIFEST.MF

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Manifest-Version: 1.0
2+
Created-By: 1.8.0_131 (Oracle Corporation)
3+

TEST/pom.xml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>oracle.kubernetes</groupId>
8+
<artifactId>weblogic-logging-exporter</artifactId>
9+
<packaging>jar</packaging>
10+
<version>1.0-SNAPSHOT</version>
11+
12+
<name>WebLogic Logging Exporter</name>
13+
<description>An exporter that integrates WLS logs into ElasticSearch and Kibana </description>
14+
15+
<url>https://orahub.oraclecorp.com/derek.sharpe/wls-logging-exporter</url>
16+
<inceptionYear>2018</inceptionYear>
17+
<licenses>
18+
<license>
19+
<name>Oracle Universal Permissive License, Version 1.0</name>
20+
<url>http://oss.oracle.com/licenses/upl</url>
21+
</license>
22+
</licenses>
23+
24+
<repositories>
25+
<repository>
26+
<releases>
27+
<enabled>true</enabled>
28+
</releases>
29+
<snapshots>
30+
<enabled>false</enabled>
31+
</snapshots>
32+
<id>maven.oracle.com</id>
33+
<url>https://maven.oracle.com</url>
34+
</repository>
35+
</repositories>
36+
<pluginRepositories>
37+
<pluginRepository>
38+
<id>maven.oracle.com</id>
39+
<url>https://maven.oracle.com</url>
40+
</pluginRepository>
41+
</pluginRepositories>
42+
43+
<build>
44+
<plugins>
45+
<plugin>
46+
<groupId>org.apache.maven.plugins</groupId>
47+
<artifactId>maven-compiler-plugin</artifactId>
48+
<version>3.6.1</version>
49+
<configuration>
50+
<source>1.8</source>
51+
<target>1.8</target>
52+
</configuration>
53+
</plugin>
54+
</plugins>
55+
</build>
56+
57+
<dependencies>
58+
<dependency>
59+
<groupId>javax</groupId>
60+
<artifactId>javaee-api</artifactId>
61+
<version>8.0</version>
62+
<scope>provided</scope>
63+
</dependency>
64+
<dependency>
65+
<groupId>com.oracle.weblogic</groupId>
66+
<artifactId>com-oracle-weblogic-logging</artifactId>
67+
<version>12.2.1-1921971</version>
68+
<scope>provided</scope>
69+
</dependency>
70+
<dependency>
71+
<groupId>com.oracle.weblogic</groupId>
72+
<artifactId>com-bea-core-logging</artifactId>
73+
<version>12.2.1-1921971</version>
74+
<scope>provided</scope>
75+
</dependency>
76+
<dependency>
77+
<groupId>com.oracle.weblogic</groupId>
78+
<artifactId>com-bea-core-diagnostics-logging</artifactId>
79+
<version>3.1.0.0-1935420.1783</version>
80+
<scope>provided</scope>
81+
</dependency>
82+
<dependency>
83+
<groupId>com.oracle.weblogic</groupId>
84+
<artifactId>com-bea-core-i18n</artifactId>
85+
<version>3.0.0.0-1933919.1781</version>
86+
<scope>provided</scope>
87+
</dependency>
88+
<dependency>
89+
<groupId>com.oracle.weblogic</groupId>
90+
<artifactId>com-bea-core-diagnostics-query</artifactId>
91+
<version>4.0.0.0-1933804.1780</version>
92+
<scope>provided</scope>
93+
</dependency>
94+
<dependency>
95+
<groupId>junit</groupId>
96+
<artifactId>junit</artifactId>
97+
<version>4.12</version>
98+
<scope>test</scope>
99+
</dependency>
100+
<dependency>
101+
<groupId>org.hamcrest</groupId>
102+
<artifactId>hamcrest-junit</artifactId>
103+
<version>2.0.0.0</version>
104+
<scope>test</scope>
105+
</dependency>
106+
<dependency>
107+
<groupId>com.meterware.simplestub</groupId>
108+
<artifactId>simplestub</artifactId>
109+
<version>1.2.8</version>
110+
<scope>test</scope>
111+
</dependency>
112+
<dependency>
113+
<groupId>org.yaml</groupId>
114+
<artifactId>snakeyaml</artifactId>
115+
<version>1.19</version>
116+
</dependency>
117+
</dependencies>
118+
</project>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright (c) 2018 Oracle and/or its affiliates
3+
*
4+
* Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
5+
*/
6+
7+
package weblogic.logging.exporter.config;
8+
9+
import java.util.Arrays;
10+
import java.util.HashMap;
11+
import java.util.Map;
12+
import org.junit.Before;
13+
import org.junit.Test;
14+
15+
import static org.hamcrest.Matchers.arrayContaining;
16+
import static org.hamcrest.junit.MatcherAssert.assertThat;
17+
18+
public class MapUtilsTest {
19+
20+
@Before
21+
public void setUp() throws Exception {}
22+
23+
@Test
24+
public void whenStringArrayValueIsStringArray_returnAsIs() {
25+
final String[] STRING_ARRAY = {"1", "2", "3"};
26+
Map<String,Object> map = createMapWithValue(STRING_ARRAY);
27+
28+
assertThat(MapUtils.getStringArray(map, "values"), arrayContaining(STRING_ARRAY));
29+
}
30+
31+
@Test
32+
public void whenStringArrayValueIsSingleObject_returnAsLengthOneArray() {
33+
Map<String,Object> map = createMapWithValue(33);
34+
35+
assertThat(MapUtils.getStringArray(map, "values"), arrayContaining("33"));
36+
}
37+
38+
@Test
39+
public void whenStringArrayValueIsList_returnAsArray() {
40+
Map<String,Object> map = createMapWithValue(Arrays.asList(7, 8, true));
41+
42+
assertThat(MapUtils.getStringArray(map, "values"), arrayContaining("7", "8", "true"));
43+
}
44+
45+
Map<String, Object> createMapWithValue(Object value) {
46+
Map<String,Object> map = new HashMap<>();
47+
map.put("values", value);
48+
return map;
49+
}
50+
}

TEST/test.jar

2.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)