Skip to content

Commit abdf891

Browse files
DEV-74217: Modified: Implementing the review comments and changing the README
1 parent e8b07c7 commit abdf891

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ The runtime stack should be set to Java version 11. The function uses the follow
3434
* `LogicMonitorCompanyName` - Company in the target URL '{company}.logicmonitor.com'
3535
* `LogicMonitorAccessId` - LogicMonitor access ID
3636
* `LogicMonitorAccessKey` - LogicMonitor access key
37+
* `AzureClientID` - Azure Application Client ID
3738
* `LogApiClientConnectTimeout` (optional) - Connection timeout in milliseconds (default 10000)
3839
* `LogApiClientReadTimeout` (optional) - Read timeout in milliseconds (default 10000)
3940
* `LogApiClientDebugging` (optional) - HTTP client debugging: true/false (default false)

package/lm-logs-azure.zip

-50 Bytes
Binary file not shown.

src/main/java/com/logicmonitor/logs/azure/LogEventAdapter.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
package com.logicmonitor.logs.azure;
1616

1717
import java.time.Instant;
18-
import java.util.*;
18+
import java.util.List;
19+
import java.util.Optional;
20+
import java.util.Set;
1921
import java.util.function.Function;
2022
import java.util.regex.Pattern;
2123
import java.util.regex.PatternSyntaxException;
@@ -58,7 +60,7 @@ public class LogEventAdapter implements Function<String, List<LogEntry>> {
5860
/**
5961
* Categories of Azure activity logs generated
6062
*/
61-
public static final Set AUDIT_LOG_CATEGORIES = new HashSet(Arrays.asList("administrative","serviceHealth","resourcehealth","alert","autoscale","security","policy","recommendation"));
63+
public static final Set AUDIT_LOG_CATEGORIES = Set.of("administrative","serviceHealth","resourcehealth","alert","autoscale","security","policy","recommendation");
6264

6365
/**
6466
* GSON instance.
@@ -118,12 +120,12 @@ public List<LogEntry> apply(String jsonString) {
118120
protected LogEntry createEntry(JsonObject json) {
119121
LogEventMessage event = GSON.fromJson(json, LogEventMessage.class);
120122
LogEntry entry = new LogEntry();
121-
if(event.getCategory() != null && AUDIT_LOG_CATEGORIES.contains(event.getCategory().toLowerCase()))
123+
if((event.getCategory() != null && AUDIT_LOG_CATEGORIES.contains(event.getCategory().toLowerCase())))
122124
{
123125
//client ID for activity logs
124126
entry.putLmResourceIdItem(LM_CLIENT_ID,azureClientId);
125127
entry.putLmResourceIdItem(LM_SYSTEM_CATEGORIES,"Azure/LMAccount");
126-
}else {
128+
} else {
127129
// resource ID
128130
entry.putLmResourceIdItem(LM_RESOURCE_PROPERTY, event.getResourceId());
129131
}

src/main/java/com/logicmonitor/logs/azure/LogEventForwarder.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
* <li>{@value #PARAMETER_READ_TIMEOUT} Read timeout in milliseconds (default 10000)
4444
* <li>{@value #PARAMETER_DEBUGGING} HTTP client debugging
4545
* <li>{@value #PARAMETER_REGEX_SCRUB} Regex to scrub text from logs
46-
* <li>{@value #PARAMETER_AZURE_CLIENT_ID} Azure Application Client ID
46+
* <li>{@value #PARAMETER_AZURE_CLIENT_ID} Azure Application Client ID
4747
* </ul>
4848
*/
4949
public class LogEventForwarder {

src/test/java/com/logicmonitor/logs/azure/LogEventAdapterTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void testApply(String resourceName, int expectedEntriesCount) {
4747

4848
@ParameterizedTest
4949
@CsvSource({
50-
"activity_storage_account.json, , ,xyz",
50+
"activity_storage_account.json, , , xyz",
5151
"activity_webapp.json, , [\\w-.#]+@[\\w-.]+ , abc",
5252
"resource_db_account.json, , \\d+\\.\\d+\\.\\d+\\.\\d+ , ",
5353
"resource_sql.json, , '\"SubscriptionId\":\"[^\"]+\",' , ",

src/test/java/com/logicmonitor/logs/azure/LogEventForwarderTest.java

+3-6
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,11 @@
1717
import static com.github.stefanbirkner.systemlambda.SystemLambda.withEnvironmentVariable;
1818
import static org.junit.jupiter.api.Assertions.*;
1919

20-
import java.net.URI;
2120
import java.util.Arrays;
2221
import java.util.List;
23-
import java.util.Map;
2422
import java.util.Set;
2523
import java.util.stream.Collectors;
2624

27-
import com.logicmonitor.logs.invoker.ServerConfiguration;
28-
import org.junit.Before;
2925
import org.junit.jupiter.params.ParameterizedTest;
3026
import org.junit.jupiter.params.provider.CsvSource;
3127
import com.logicmonitor.logs.LMLogsApi;
@@ -115,11 +111,12 @@ public void testProcessEvents(String resourceName, int expectedEntriesCount) thr
115111
() -> assertEquals(expectedEntriesCount, entries.size()),
116112
() -> entries.forEach(entry -> assertNotNull(entry.getMessage())),
117113
() -> entries.forEach(entry -> assertNotNull(entry.getTimestamp())),
118-
() -> entries.forEach((entry) ->{
114+
() -> entries.forEach((entry) -> {
119115
if (entry.getLmResourceId().containsKey(LogEventAdapter.LM_CLIENT_ID))
120116
assertNotNull(entry.getLmResourceId().get(LogEventAdapter.LM_CLIENT_ID));
121117
else assertNotNull(
122-
entry.getLmResourceId().get(LogEventAdapter.LM_RESOURCE_PROPERTY));})
118+
entry.getLmResourceId().get(LogEventAdapter.LM_RESOURCE_PROPERTY));
119+
})
123120
);
124121
});
125122
}

0 commit comments

Comments
 (0)