Skip to content

Commit 33f31bf

Browse files
authored
Merge pull request #79 from logicmonitor/develop
Need domain support for govcloud | Keeping TLS version configurable in the template
2 parents 0719c77 + 3a8026e commit 33f31bf

File tree

7 files changed

+113
-78
lines changed

7 files changed

+113
-78
lines changed

arm-template-deployment/deployRGParent.json

+58-31
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,50 @@
22
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
33
"contentVersion": "1.0.0.0",
44
"variables": {
5-
"sourceCodeBranch" : "master",
5+
"sourceCodeBranch": "master",
66
"templateBaseUri": "[concat('https://raw.githubusercontent.com/logicmonitor/lm-logs-azure/',variables('sourceCodeBranch'),'/arm-template-deployment/')]",
7-
"deploymentResourceGroupName": "[concat('lm-logs','-',parameters('LM_Company_name'), '-', replace(parameters('resource_group_region'),' ',''),'-group')]",
8-
"eventhubNamespace": "[concat('lm-logs','-',parameters('LM_Company_name'), '-', replace(parameters('resource_group_region'),' ',''))]",
7+
"deploymentResourceGroupName": "[concat('lm-logs','-',parameters('LM_Company_Name'), '-', replace(parameters('Resource_Group_Region'),' ',''),'-group')]",
8+
"eventhubNamespace": "[concat('lm-logs','-',parameters('LM_Company_Name'), '-', replace(parameters('Resource_Group_Region'),' ',''))]",
99
"eventhubLogsName": "log-hub",
1010
"subscriptionId": "[subscription().subscriptionId]",
1111
"eventHubAuthorizationRuleId": "[concat('/subscriptions/', variables('subscriptionId'), '/resourceGroups/', variables('deploymentResourceGroupName'), '/providers/Microsoft.EventHub/namespaces/', variables('eventhubNamespace'), '/authorizationRules/RootManageSharedAccessKey')]"
1212
},
1313
"parameters": {
14-
"resource_group_region": {
14+
"Resource_Group_Region": {
1515
"type": "String"
1616
},
17-
"LM_Company_name": {
17+
"LM_Company_Name": {
1818
"type": "String"
1919
},
20+
"LM_Domain_Name": {
21+
"type": "string",
22+
"defaultValue": "logicmonitor.com",
23+
"allowedValues": [
24+
"logicmonitor.com",
25+
"lmgov.us",
26+
"qa-lmgov.us"
27+
],
28+
"metadata": {
29+
"description": "Domain of LM Platform where logs are to be sent."
30+
}
31+
},
2032
"LM_Access_Id": {
2133
"type": "String",
22-
"defaultValue":"",
34+
"defaultValue": "",
2335
"metadata": {
2436
"description": "LogicMonitor API Token access ID."
2537
}
2638
},
2739
"LM_Access_Key": {
2840
"type": "String",
29-
"defaultValue":"",
41+
"defaultValue": "",
3042
"metadata": {
3143
"description": "LogicMonitor API Token access Key."
3244
}
3345
},
3446
"LM_Bearer_Token": {
3547
"type": "String",
36-
"defaultValue":"",
48+
"defaultValue": "",
3749
"metadata": {
3850
"description": "LM API Bearer Token.\nEither specify access_id and access_key both or bearer_token. If all specified, LMv1 token(access_id and access_key) will be used for authentication with LogicMonitor."
3951
}
@@ -46,33 +58,26 @@
4658
},
4759
"Azure_Account_Name": {
4860
"type": "string",
49-
"defaultValue":"",
61+
"defaultValue": "",
5062
"metadata": {
5163
"description": "Azure Account Name created during the creation of azure account in LM"
5264
}
5365
},
5466
"Include_Metadata_keys": {
5567
"type": "string",
56-
"defaultValue":"resourceId",
68+
"defaultValue": "resourceId",
5769
"metadata": {
5870
"description": "comma separated keys to add as event metadata in a lm-log event. for nested json specify '.' eg - properties.functionName,properties.message "
5971
}
6072
},
61-
"LMTenantId": {
73+
"LM_Tenant_Id": {
6274
"type": "string",
63-
"defaultValue":"",
75+
"defaultValue": "",
6476
"metadata": {
6577
"description": "LogicMonitor Tenant Identifier sent as event metadata to LogicMonitor"
6678
}
6779
},
68-
"Resource_Type": {
69-
"type": "string",
70-
"defaultValue": "Azure",
71-
"metadata": {
72-
"description": "Type of platform from where logs are coming."
73-
}
74-
},
75-
"enableActivityLogs": {
80+
"Enable_Activity_Logs": {
7681
"type": "String",
7782
"allowedValues": [
7883
"Yes",
@@ -82,14 +87,30 @@
8287
"description": "Enable Activity logs to be sent to the event hub that will get created in this deployment"
8388
},
8489
"defaultValue": "Yes"
90+
},
91+
"TLSVersionStorageAccount": {
92+
"type": "string",
93+
"defaultValue": "1_2",
94+
"metadata": {
95+
"description": "Provide an appropriate TLS version for storage account. Format - X_X"
96+
}
97+
},
98+
"TLSVersionFunctionApp": {
99+
"type": "string",
100+
"defaultValue": "1.3",
101+
"metadata": {
102+
"description": "Provide an appropriate TLS version for function app. Format - X.X"
103+
}
85104
}
105+
106+
86107
},
87108
"resources": [
88109
{
89110
"condition": "[or(and(not(empty(parameters('LM_Access_Id'))), not(empty(parameters('LM_Access_Key')))), not(empty(parameters('LM_Bearer_Token'))))]",
90111
"type": "Microsoft.Resources/resourceGroups",
91112
"apiVersion": "2018-05-01",
92-
"location": "[parameters('resource_group_region')]",
113+
"location": "[parameters('Resource_Group_Region')]",
93114
"name": "[variables('deploymentResourceGroupName')]",
94115
"properties": {}
95116
},
@@ -106,11 +127,14 @@
106127
"contentVersion": "1.0.0.0"
107128
},
108129
"parameters": {
109-
"azure_region": {
110-
"value": "[parameters('resource_group_region')]"
130+
"Azure_Region": {
131+
"value": "[parameters('Resource_Group_Region')]"
111132
},
112-
"LM_Company_name": {
113-
"value": "[parameters('LM_Company_name')]"
133+
"LM_Company_Name": {
134+
"value": "[parameters('LM_Company_Name')]"
135+
},
136+
"LM_Domain_Name": {
137+
"value": "[parameters('LM_Domain_Name')]"
114138
},
115139
"LM_Access_Id": {
116140
"value": "[parameters('LM_Access_Id')]"
@@ -133,11 +157,14 @@
133157
"Include_Metadata_keys": {
134158
"value": "[parameters('Include_Metadata_keys')]"
135159
},
136-
"LMTenantId" : {
137-
"value": "[parameters('LMTenantId')]"
160+
"LM_Tenant_Id" : {
161+
"value": "[parameters('LM_Tenant_Id')]"
162+
},
163+
"TLSVersionStorageAccount": {
164+
"value": "[parameters('TLSVersionStorageAccount')]"
138165
},
139-
"Resource_Type": {
140-
"value": "[parameters('Resource_Type')]"
166+
"TLSVersionFunctionApp": {
167+
"value": "[parameters('TLSVersionFunctionApp')]"
141168
}
142169
}
143170
},
@@ -146,7 +173,7 @@
146173
]
147174
},
148175
{
149-
"condition": "[equals(parameters('enableActivityLogs'), 'Yes')]",
176+
"condition": "[equals(parameters('Enable_Activity_Logs'), 'Yes')]",
150177
"type": "Microsoft.Insights/diagnosticSettings",
151178
"apiVersion": "2017-05-01-preview",
152179
"name": "[variables('deploymentResourceGroupName')]",
@@ -195,4 +222,4 @@
195222
}
196223
],
197224
"outputs": {}
198-
}
225+
}

arm-template-deployment/deployResourcesInRG.json

+28-20
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
33
"contentVersion": "1.0.0.0",
44
"parameters": {
5-
"LM_Company_name": {
5+
"LM_Company_Name": {
66
"type": "string"
77
},
88
"LM_Access_Id": {
@@ -23,30 +23,37 @@
2323
"Include_Metadata_keys": {
2424
"type": "string"
2525
},
26-
"LMTenantId": {
26+
"LM_Tenant_Id": {
2727
"type": "string"
2828
},
29-
"azure_region": {
29+
"Azure_Region": {
3030
"type": "string"
3131
},
3232
"sourceCodeBranch": {
3333
"type": "string"
3434
},
35-
"Resource_Type": {
35+
"LM_Domain_Name": {
3636
"type": "string"
37+
},
38+
"TLSVersionStorageAccount" : {
39+
"type" : "string"
40+
},
41+
"TLSVersionFunctionApp" : {
42+
"type" : "string"
3743
}
3844
},
3945
"variables": {
40-
"logsFunctionAppName": "[concat('lm-logs','-',parameters('LM_Company_name'), '-', replace(parameters('azure_region'),' ',''))]",
41-
"eventhubNamespace": "[concat('lm-logs','-',parameters('LM_Company_name'), '-', replace(parameters('azure_region'),' ',''))]",
42-
"storage": "[toLower(concat(parameters('LM_Company_name'), replace(parameters('azure_region'),' ','')))]",
46+
"logsFunctionAppName": "[concat('lm-logs','-',parameters('LM_Company_Name'), '-', replace(parameters('Azure_Region'),' ',''))]",
47+
"eventhubNamespace": "[concat('lm-logs','-',parameters('LM_Company_Name'), '-', replace(parameters('Azure_Region'),' ',''))]",
48+
"storage": "[toLower(concat(parameters('LM_Company_Name'), replace(parameters('Azure_Region'),' ','')))]",
4349
"lmAppStorageAccounts": "[if(greater(length(variables('storage')) , 24), substring(variables('storage'), sub(length(variables('storage')) , 24), 24) , variables('storage'))]",
4450
"eventhubLogsName": "log-hub",
4551
"ConsumergroupsLogsName": "LMConsumerGroup",
4652
"functionServerfarms": "[concat(variables('eventhubNamespace'),'-service-plan')]",
4753
"listener": "listener",
4854
"sender": "sender",
49-
"lm_auth": "[concat('{ \"LM_ACCESS_ID\" : \"',parameters('LM_Access_Id'),'\", \"LM_ACCESS_KEY\" : \"', parameters('LM_Access_Key'), '\", \"LM_BEARER_TOKEN\" : \"', parameters('LM_Bearer_Token'), '\" }')]"
55+
"lm_auth": "[concat('{ \"LM_ACCESS_ID\" : \"',parameters('LM_Access_Id'),'\", \"LM_ACCESS_KEY\" : \"', parameters('LM_Access_Key'), '\", \"LM_BEARER_TOKEN\" : \"', parameters('LM_Bearer_Token'), '\" }')]",
56+
"tlsVersionStorageAccount" : "[concat('TLS',parameters('TLSVersionStorageAccount'))]"
5057
},
5158
"resources": [
5259
{
@@ -74,7 +81,7 @@
7481
"apiVersion": "2019-06-01",
7582
"location": "[resourceGroup().location]",
7683
"properties": {
77-
"minimumTlsVersion": "TLS1_2",
84+
"minimumTlsVersion": "[variables('tlsVersionStorageAccount')]",
7885
"encryption": {
7986
"services": {
8087
"file": {
@@ -159,15 +166,15 @@
159166
},
160167
{
161168
"name": "LM_COMPANY",
162-
"value": "[parameters('LM_Company_name')]"
169+
"value": "[parameters('LM_Company_Name')]"
163170
},
164171
{
165-
"name" : "LM_AUTH",
166-
"value" : "[variables('lm_auth')]"
172+
"name": "LM_AUTH",
173+
"value": "[variables('lm_auth')]"
167174
},
168175
{
169-
"name" : "LM_TENANT_ID",
170-
"value" : "[parameters('LMTenantId')]"
176+
"name": "LM_TENANT_ID",
177+
"value": "[parameters('LM_Tenant_Id')]"
171178
},
172179
{
173180
"name": "AzureClientID",
@@ -199,17 +206,18 @@
199206
},
200207
{
201208
"name": "Include_Metadata_keys",
202-
"value" : "[parameters('Include_Metadata_keys')]"
209+
"value": "[parameters('Include_Metadata_keys')]"
203210
},
204211
{
205212
"name": "LOG_LEVEL",
206-
"value" : "WARNING"
213+
"value": "WARNING"
207214
},
208215
{
209-
"name": "RESOURCE_TYPE",
210-
"value": "[Parameters('Resource_Type')]"
216+
"name": "LM_DOMAIN_NAME",
217+
"value": "[parameters('LM_Domain_Name')]"
211218
}
212-
]
219+
],
220+
"minTlsVersion" : "[parameters('TLSVersionFunctionApp')]"
213221
}
214222
},
215223
"dependsOn": [
@@ -275,4 +283,4 @@
275283
]
276284
}
277285
]
278-
}
286+
}

build.gradle

+15-15
Original file line numberDiff line numberDiff line change
@@ -25,32 +25,32 @@ repositories {
2525
}
2626

2727
dependencies {
28-
implementation (
29-
"com.microsoft.azure.functions:azure-functions-java-library:1.4.0",
30-
"com.logicmonitor:lm-logs-sdk-java:1.2",
31-
"com.logicmonitor:lm-data-sdk:0.0.4-alpha",
32-
"com.google.code.gson:gson:2.8.6"
28+
implementation(
29+
"com.logicmonitor:lm-data-sdk:0.0.5-alpha",
30+
"com.microsoft.azure.functions:azure-functions-java-library:1.4.0",
31+
"com.logicmonitor:lm-logs-sdk-java:1.2",
32+
"com.google.code.gson:gson:2.8.6"
3333
)
34-
implementation 'com.squareup.okhttp3:okhttp:4.9.3'
34+
implementation 'com.squareup.okhttp3:okhttp:4.9.3'
3535
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.3'
3636
implementation 'io.gsonfire:gson-fire:1.8.5'
3737
implementation 'org.slf4j:slf4j-api:1.7.25'
3838
implementation 'org.apache.commons:commons-lang3:3.9'
3939
implementation 'com.jayway.jsonpath:json-path:2.5.0'
4040
implementation 'org.slf4j:slf4j-nop:1.7.25'
4141

42-
testImplementation (
43-
"org.junit.jupiter:junit-jupiter:${junitVersion}",
44-
"com.github.stefanbirkner:system-lambda:1.0.0",
45-
"org.mockito:mockito-core:3.4.4",
46-
"org.glassfish.jersey.test-framework:jersey-test-framework-core:${jerseyVersion}",
47-
"org.glassfish.jersey.test-framework.providers:jersey-test-framework-provider-grizzly2:${jerseyVersion}"
42+
testImplementation(
43+
"org.junit.jupiter:junit-jupiter:${junitVersion}",
44+
"com.github.stefanbirkner:system-lambda:1.0.0",
45+
"org.mockito:mockito-core:3.4.4",
46+
"org.glassfish.jersey.test-framework:jersey-test-framework-core:${jerseyVersion}",
47+
"org.glassfish.jersey.test-framework.providers:jersey-test-framework-provider-grizzly2:${jerseyVersion}"
4848
)
4949
testCompileOnly(
50-
"junit:junit:4.12"
50+
"junit:junit:4.12"
5151
)
5252
testRuntimeOnly(
53-
"org.junit.vintage:junit-vintage-engine:${junitVersion}"
53+
"org.junit.vintage:junit-vintage-engine:${junitVersion}"
5454
)
5555
}
5656

@@ -68,7 +68,7 @@ test {
6868
jar {
6969
manifest {
7070
attributes 'Implementation-Title': project.getName(),
71-
'Implementation-Version': project.getVersion()
71+
'Implementation-Version': project.getVersion()
7272
}
7373
}
7474

local.settings.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"LOG_LEVEL" : "WARNING",
1818
"LM_TENANT_ID" : "sample_tenant_id",
1919
"LM_AUTH": "{\"LM_ACCESS_ID\": \"id\", \"LM_ACCESS_KEY\" : \"key\", \"LM_BEARER_TOKEN\" : \"token\"}",
20-
"AzureAccountName": "LMTest Account",
21-
"RESOURCE_TYPE": "Azure"
20+
"AzureAccountName": "<Logicmonitor Azure Account>",
21+
"LM_DOMAIN_NAME" : "<LogicMonitor company domain>"
2222
}
2323
}

package/lm-logs-azure.zip

88.1 KB
Binary file not shown.

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

+1-8
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,6 @@ public class LogEventAdapter implements Function<String, List<LogEntry>> {
102102
public static final String AZURE_CATEGORY = "category";
103103
public static final String LM_TENANT_ID = "LM_TENANT_ID";
104104

105-
public static final String RESOURCE_TYPE_KEY = "RESOURCE_TYPE";
106-
public static final String RESOURCE_TYPE_FIELD = "_resource.type";
107105
public static final String LM_TENANT_ID_KEY = "_lm.tenantId";
108106

109107
public static final Pattern RESOURCE_TYPE = Pattern.compile("/subscriptions/.*/resourceGroups/.*/providers/(?<type>[^/]*/[^/]*)/.*", Pattern.CASE_INSENSITIVE);
@@ -115,7 +113,7 @@ public class LogEventAdapter implements Function<String, List<LogEntry>> {
115113
/**
116114
* Required static metadata to be added in every LogEntry.
117115
*/
118-
public static final Map<String, String> REQ_STATIC_METADATA = Map.of("_integration", "azure");
116+
public static final Map<String, String> REQ_STATIC_METADATA = Map.of("_integration", "azure", "_resource.type", "Azure");
119117

120118
/**
121119
* Required metadata key to LogEventMessage method map.
@@ -254,11 +252,6 @@ protected LogEntry createEntry(JsonObject json) {
254252
metadata.put(LM_TENANT_ID_KEY, tenantId);
255253
}
256254

257-
String resourceType = System.getenv(RESOURCE_TYPE_KEY);
258-
if(StringUtils.isNotBlank(resourceType)){
259-
metadata.put(RESOURCE_TYPE_FIELD, resourceType);
260-
}
261-
262255
entry.setMetadata(metadata);
263256
if (scrubPattern != null) {
264257
message = scrubPattern.matcher(message).replaceAll("");

0 commit comments

Comments
 (0)