Skip to content

Commit 5a00f7e

Browse files
authored
New module (logan_sources) to import custom content (#4)
* Create import_contents.py import custom content changes * Create main.tf * Create variables.tf * Create variables.tf * Create main.tf * Create provider.tf.example * Create terraform.tfvars.example * Update main.tf update module path * Create src11.xml * Create src12.xml * Create src21.xml * Create src22.xml * Update variables.tf * Update main.tf * Update variables.tf remove namespace * Update main.tf remove namespace * Update main.tf Update the import_contents.py path * Create README.md * Create README.md * Update variables.tf remove unused variables * Update README.md Update details about configuration file required for making sdk calls * Update README.md * Update main.tf Add copyright * Update terraform.tfvars.example Add copyright * Update main.tf Add copyright * Update variables.tf Add copyright * Update import_contents.py Add copyright * Update variables.tf
1 parent 1501789 commit 5a00f7e

File tree

13 files changed

+533
-0
lines changed

13 files changed

+533
-0
lines changed

examples/logan_sources/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## Import custom content after substituting property values
2+
3+
This example is to import custom contents from the content path provided as input. It iterates over each content xml listed in the content path and substitute the property name with value from schema_names map and then imports the custom contents.
4+
5+
Rename the provider.tf.example to provider.tf and provide the required values
6+
7+
Also rename the terraform.tfvars.example to terraform.tfvars and provide products value as a comma separated product names string. And property name value map in schema_names as shown in the example.
8+
9+
Make sure that the configuration file is placed at default location(~/.oci/) by populating the user and tenancy details as follows
10+
```console
11+
[DEFAULT]
12+
user=<user OCID>
13+
fingerprint=<user_fingerprint>
14+
key_file=<pem file location>
15+
tenancy=<tenancy OCID>
16+
region=<oci region>
17+
```
18+
19+
Run the terraform commands to execute
20+
```console
21+
terraform init
22+
terraform plan
23+
terraform apply
24+
```
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<LoganContent xmlns="http://www.oracle.com/DataCenter/LogAnalyticsStd" content_version="2.66.1.0.0" name="content_ocid1.tenancy.oc1..aaaaaaaa2biiw2clmshec34nq7rcdn2ga6q34rwq3erddvdht5qd4xbaex2a_1683637479590" oms_version="2.66.1.0.0">
3+
<Field oms_version="2.66.1.0.0">
4+
<DisplayName>#Backend Status Code</DisplayName>
5+
<Description>Shows a response code received from the backend</Description>
6+
<FieldType>1</FieldType>
7+
<IsSystem>0</IsSystem>
8+
<IsPrimary>1</IsPrimary>
9+
<DataType>INTEGER</DataType>
10+
<IsMetricKeyEligible>0</IsMetricKeyEligible>
11+
<IsMetricValueEligible>0</IsMetricValueEligible>
12+
<FacetEligible>1</FacetEligible>
13+
<RangeFacetEligible>0</RangeFacetEligible>
14+
<TableEligible>1</TableEligible>
15+
<FacetPriority>1</FacetPriority>
16+
<Summarizable>1</Summarizable>
17+
<HighCardinality>1</HighCardinality>
18+
<LargeData>0</LargeData>
19+
<MultiValued>0</MultiValued>
20+
<SMAEnabledSetting>0</SMAEnabledSetting>
21+
</Field>
22+
<Source configWarningSettings="0" name="mvTestSrc1" oms_version="2.66.1.0.0">
23+
<SourceType>os_file</SourceType>
24+
<TargetTypes>
25+
<TargetType>omc_host_linux</TargetType>
26+
</TargetTypes>
27+
<DisplayName>mvTestSrc1</DisplayName>
28+
<IsSystem>0</IsSystem>
29+
<IsSecureContent>1</IsSecureContent>
30+
<Patterns>
31+
<Pattern>
32+
<Value>/{SCHEMA2}/var/{SCHEMA1}/access_log11</Value>
33+
<IsInclude>1</IsInclude>
34+
<InUse>1</InUse>
35+
<IsSystem>0</IsSystem>
36+
<IsEnabled>1</IsEnabled>
37+
</Pattern>
38+
</Patterns>
39+
<Parsers>
40+
<Parser>
41+
<ParserSeq>1</ParserSeq>
42+
<ParserName>host_httpdaccesslog_logtype</ParserName>
43+
</Parser>
44+
</Parsers>
45+
<MdFieldReferences>
46+
<MdFieldReference key="#Backend Status Code">
47+
<FieldName>udfi1</FieldName>
48+
<IsSystem>0</IsSystem>
49+
<IsEnabled>1</IsEnabled>
50+
</MdFieldReference>
51+
<MdFieldReference key="Access Mask">
52+
<FieldName>accmask</FieldName>
53+
<IsSystem>0</IsSystem>
54+
<IsEnabled>1</IsEnabled>
55+
</MdFieldReference>
56+
</MdFieldReferences>
57+
<TagConditions>
58+
<TagCondition alertRuleVisible="0" field="method" operator="CONTAINS">
59+
<ConditionValues>
60+
<ConditionValue>select</ConditionValue>
61+
</ConditionValues>
62+
<ConditionTags tagField="mtag">
63+
<ConditionTag>actnstart</ConditionTag>
64+
</ConditionTags>
65+
<IsSystem>0</IsSystem>
66+
<IsEnabled>1</IsEnabled>
67+
</TagCondition>
68+
</TagConditions>
69+
<SourceFunctions>
70+
<SourceFunction lookupMode="0" name="Geolocation" order="101" overrideOutputFields="1">
71+
<SourceInputFields>
72+
<InputField lkCol="IP Field" order="1">method</InputField>
73+
</SourceInputFields>
74+
<SourceOutputFields>
75+
<OutputField lkCol="Continent" order="1">continentclnt</OutputField>
76+
<OutputField lkCol="Country Code" order="4">countrycodeclnt</OutputField>
77+
<OutputField lkCol="Coordinates" order="8">geolocclnt</OutputField>
78+
<OutputField lkCol="Continent Code" order="2">continentcodeclnt</OutputField>
79+
<OutputField lkCol="City" order="7">cityclnt</OutputField>
80+
<OutputField lkCol="Country" order="3">countryclnt</OutputField>
81+
<OutputField lkCol="State Code" order="6">regioncodeclnt</OutputField>
82+
<OutputField lkCol="State" order="5">regionclnt</OutputField>
83+
</SourceOutputFields>
84+
<SourceFunctionFeatures>
85+
<FunctionFeature>
86+
<Name>Geolocation</Name>
87+
</FunctionFeature>
88+
</SourceFunctionFeatures>
89+
<IsSystem>0</IsSystem>
90+
<IsEnabled>1</IsEnabled>
91+
</SourceFunction>
92+
</SourceFunctions>
93+
<IsHidden>0</IsHidden>
94+
<IsSMAEnabled>0</IsSMAEnabled>
95+
<EventTypes>
96+
<EventType>
97+
<Name>test2</Name>
98+
<SpecVersion>1.0</SpecVersion>
99+
<IsEnabled>1</IsEnabled>
100+
<IsSystem>0</IsSystem>
101+
</EventType>
102+
</EventTypes>
103+
</Source>
104+
<FieldNameMaps>
105+
<FieldNameMap>
106+
<Name>udfi1</Name>
107+
<DisplayName>#Backend Status Code</DisplayName>
108+
</FieldNameMap>
109+
</FieldNameMaps>
110+
</LoganContent>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<LoganContent xmlns="http://www.oracle.com/DataCenter/LogAnalyticsStd" content_version="2.66.1.0.0" name="content_ocid1.tenancy.oc1..aaaaaaaa2biiw2clmshec34nq7rcdn2ga6q34rwq3erddvdht5qd4xbaex2a_1683637487119" oms_version="2.66.1.0.0">
3+
<Source configWarningSettings="0" name="mvTestSrc2" oms_version="2.66.1.0.0">
4+
<SourceType>os_file</SourceType>
5+
<TargetTypes>
6+
<TargetType>omc_host_linux</TargetType>
7+
</TargetTypes>
8+
<DisplayName>mvTestSrc2</DisplayName>
9+
<IsSystem>0</IsSystem>
10+
<IsSecureContent>1</IsSecureContent>
11+
<Patterns>
12+
<Pattern>
13+
<Value>/{SCHEMA1}/var/{SCHEMA2}/tmp/access_log22</Value>
14+
<IsInclude>1</IsInclude>
15+
<InUse>1</InUse>
16+
<IsSystem>0</IsSystem>
17+
<IsEnabled>1</IsEnabled>
18+
</Pattern>
19+
</Patterns>
20+
<Parsers>
21+
<Parser>
22+
<ParserSeq>1</ParserSeq>
23+
<ParserName>host_httpdaccesslog_logtype</ParserName>
24+
</Parser>
25+
</Parsers>
26+
<IsHidden>0</IsHidden>
27+
<IsSMAEnabled>0</IsSMAEnabled>
28+
</Source>
29+
</LoganContent>
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<LoganContent xmlns="http://www.oracle.com/DataCenter/LogAnalyticsStd" content_version="2.66.1.0.0" name="content_ocid1.tenancy.oc1..aaaaaaaa2biiw2clmshec34nq7rcdn2ga6q34rwq3erddvdht5qd4xbaex2a_1683637479590" oms_version="2.66.1.0.0">
3+
<Field oms_version="2.66.1.0.0">
4+
<DisplayName>#Backend Status Code</DisplayName>
5+
<Description>Shows a response code received from the backend</Description>
6+
<FieldType>1</FieldType>
7+
<IsSystem>0</IsSystem>
8+
<IsPrimary>1</IsPrimary>
9+
<DataType>INTEGER</DataType>
10+
<IsMetricKeyEligible>0</IsMetricKeyEligible>
11+
<IsMetricValueEligible>0</IsMetricValueEligible>
12+
<FacetEligible>1</FacetEligible>
13+
<RangeFacetEligible>0</RangeFacetEligible>
14+
<TableEligible>1</TableEligible>
15+
<FacetPriority>1</FacetPriority>
16+
<Summarizable>1</Summarizable>
17+
<HighCardinality>1</HighCardinality>
18+
<LargeData>0</LargeData>
19+
<MultiValued>0</MultiValued>
20+
<SMAEnabledSetting>0</SMAEnabledSetting>
21+
</Field>
22+
<Source configWarningSettings="0" name="mvTestSrc1" oms_version="2.66.1.0.0">
23+
<SourceType>os_file</SourceType>
24+
<TargetTypes>
25+
<TargetType>omc_host_linux</TargetType>
26+
</TargetTypes>
27+
<DisplayName>mvTestSrc1</DisplayName>
28+
<IsSystem>0</IsSystem>
29+
<IsSecureContent>1</IsSecureContent>
30+
<Patterns>
31+
<Pattern>
32+
<Value>/{SCHEMA2}/var/{SCHEMA1}/access_log11</Value>
33+
<IsInclude>1</IsInclude>
34+
<InUse>1</InUse>
35+
<IsSystem>0</IsSystem>
36+
<IsEnabled>1</IsEnabled>
37+
</Pattern>
38+
</Patterns>
39+
<Parsers>
40+
<Parser>
41+
<ParserSeq>1</ParserSeq>
42+
<ParserName>host_httpdaccesslog_logtype</ParserName>
43+
</Parser>
44+
</Parsers>
45+
<MdFieldReferences>
46+
<MdFieldReference key="#Backend Status Code">
47+
<FieldName>udfi1</FieldName>
48+
<IsSystem>0</IsSystem>
49+
<IsEnabled>1</IsEnabled>
50+
</MdFieldReference>
51+
<MdFieldReference key="Access Mask">
52+
<FieldName>accmask</FieldName>
53+
<IsSystem>0</IsSystem>
54+
<IsEnabled>1</IsEnabled>
55+
</MdFieldReference>
56+
</MdFieldReferences>
57+
<TagConditions>
58+
<TagCondition alertRuleVisible="0" field="method" operator="CONTAINS">
59+
<ConditionValues>
60+
<ConditionValue>select</ConditionValue>
61+
</ConditionValues>
62+
<ConditionTags tagField="mtag">
63+
<ConditionTag>actnstart</ConditionTag>
64+
</ConditionTags>
65+
<IsSystem>0</IsSystem>
66+
<IsEnabled>1</IsEnabled>
67+
</TagCondition>
68+
</TagConditions>
69+
<SourceFunctions>
70+
<SourceFunction lookupMode="0" name="Geolocation" order="101" overrideOutputFields="1">
71+
<SourceInputFields>
72+
<InputField lkCol="IP Field" order="1">method</InputField>
73+
</SourceInputFields>
74+
<SourceOutputFields>
75+
<OutputField lkCol="Continent" order="1">continentclnt</OutputField>
76+
<OutputField lkCol="Country Code" order="4">countrycodeclnt</OutputField>
77+
<OutputField lkCol="Coordinates" order="8">geolocclnt</OutputField>
78+
<OutputField lkCol="Continent Code" order="2">continentcodeclnt</OutputField>
79+
<OutputField lkCol="City" order="7">cityclnt</OutputField>
80+
<OutputField lkCol="Country" order="3">countryclnt</OutputField>
81+
<OutputField lkCol="State Code" order="6">regioncodeclnt</OutputField>
82+
<OutputField lkCol="State" order="5">regionclnt</OutputField>
83+
</SourceOutputFields>
84+
<SourceFunctionFeatures>
85+
<FunctionFeature>
86+
<Name>Geolocation</Name>
87+
</FunctionFeature>
88+
</SourceFunctionFeatures>
89+
<IsSystem>0</IsSystem>
90+
<IsEnabled>1</IsEnabled>
91+
</SourceFunction>
92+
</SourceFunctions>
93+
<IsHidden>0</IsHidden>
94+
<IsSMAEnabled>0</IsSMAEnabled>
95+
<EventTypes>
96+
<EventType>
97+
<Name>test2</Name>
98+
<SpecVersion>1.0</SpecVersion>
99+
<IsEnabled>1</IsEnabled>
100+
<IsSystem>0</IsSystem>
101+
</EventType>
102+
</EventTypes>
103+
</Source>
104+
<FieldNameMaps>
105+
<FieldNameMap>
106+
<Name>udfi1</Name>
107+
<DisplayName>#Backend Status Code</DisplayName>
108+
</FieldNameMap>
109+
</FieldNameMaps>
110+
</LoganContent>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<LoganContent xmlns="http://www.oracle.com/DataCenter/LogAnalyticsStd" content_version="2.66.1.0.0" name="content_ocid1.tenancy.oc1..aaaaaaaa2biiw2clmshec34nq7rcdn2ga6q34rwq3erddvdht5qd4xbaex2a_1683637487119" oms_version="2.66.1.0.0">
3+
<Source configWarningSettings="0" name="mvTestSrc2" oms_version="2.66.1.0.0">
4+
<SourceType>os_file</SourceType>
5+
<TargetTypes>
6+
<TargetType>omc_host_linux</TargetType>
7+
</TargetTypes>
8+
<DisplayName>mvTestSrc2</DisplayName>
9+
<IsSystem>0</IsSystem>
10+
<IsSecureContent>1</IsSecureContent>
11+
<Patterns>
12+
<Pattern>
13+
<Value>/{SCHEMA1}/var/{SCHEMA2}/tmp/access_log22</Value>
14+
<IsInclude>1</IsInclude>
15+
<InUse>1</InUse>
16+
<IsSystem>0</IsSystem>
17+
<IsEnabled>1</IsEnabled>
18+
</Pattern>
19+
</Patterns>
20+
<Parsers>
21+
<Parser>
22+
<ParserSeq>1</ParserSeq>
23+
<ParserName>host_httpdaccesslog_logtype</ParserName>
24+
</Parser>
25+
</Parsers>
26+
<IsHidden>0</IsHidden>
27+
<IsSMAEnabled>0</IsSMAEnabled>
28+
</Source>
29+
</LoganContent>

examples/logan_sources/main.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#Copyright (c) 2023 Oracle Corporation and/or its affiliates.
2+
#Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl
3+
4+
module "logan_sources" {
5+
source = "../../modules/logan_sources"
6+
schema_names = var.schema_names
7+
for_each = toset(split(",", var.products))
8+
path = format("%s/%s", "./contents/sources", each.value)
9+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#Copyright (c) 2023 Oracle Corporation and/or its affiliates.
2+
#Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl
3+
4+
provider "oci" {
5+
region = "<region where custom content to be imported>"
6+
fingerprint = ""
7+
private_key_path = ""
8+
9+
tenancy_ocid = ""
10+
user_ocid = ""
11+
12+
}
13+
14+
terraform {
15+
required_providers {
16+
oci = {
17+
source = "oracle/oci"
18+
version = ">= 4.67.3"
19+
}
20+
}
21+
required_version = ">= 1.3.0"
22+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#Copyright (c) 2023 Oracle Corporation and/or its affiliates.
2+
#Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl
3+
4+
products="Oracle Adv1,Oracle Asts1"
5+
schema_names={
6+
"{SCHEMA1}" = "ABC"
7+
"{SCHEMA2}" = "XYZ"
8+
}

examples/logan_sources/variables.tf

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright (c) 2023, Oracle and/or its affiliates.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
4+
variable "config_file_profile" {
5+
default = "DEFAULT"
6+
}
7+
8+
variable "auth_type" {
9+
default = "user"
10+
}
11+
12+
variable "products" {
13+
type = string
14+
}
15+
16+
variable "schema_names" {
17+
type = map
18+
default = {
19+
"abc" = "xyz"
20+
}
21+
}

0 commit comments

Comments
 (0)