Skip to content

Commit

Permalink
New module (logan_sources) to import custom content (#4)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
mvmaths authored Jun 28, 2023
1 parent 1501789 commit 5a00f7e
Show file tree
Hide file tree
Showing 13 changed files with 533 additions and 0 deletions.
24 changes: 24 additions & 0 deletions examples/logan_sources/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## Import custom content after substituting property values

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.

Rename the provider.tf.example to provider.tf and provide the required values

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.

Make sure that the configuration file is placed at default location(~/.oci/) by populating the user and tenancy details as follows
```console
[DEFAULT]
user=<user OCID>
fingerprint=<user_fingerprint>
key_file=<pem file location>
tenancy=<tenancy OCID>
region=<oci region>
```

Run the terraform commands to execute
```console
terraform init
terraform plan
terraform apply
```
110 changes: 110 additions & 0 deletions examples/logan_sources/contents/sources/Oracle Adv1/src11.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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">
<Field oms_version="2.66.1.0.0">
<DisplayName>#Backend Status Code</DisplayName>
<Description>Shows a response code received from the backend</Description>
<FieldType>1</FieldType>
<IsSystem>0</IsSystem>
<IsPrimary>1</IsPrimary>
<DataType>INTEGER</DataType>
<IsMetricKeyEligible>0</IsMetricKeyEligible>
<IsMetricValueEligible>0</IsMetricValueEligible>
<FacetEligible>1</FacetEligible>
<RangeFacetEligible>0</RangeFacetEligible>
<TableEligible>1</TableEligible>
<FacetPriority>1</FacetPriority>
<Summarizable>1</Summarizable>
<HighCardinality>1</HighCardinality>
<LargeData>0</LargeData>
<MultiValued>0</MultiValued>
<SMAEnabledSetting>0</SMAEnabledSetting>
</Field>
<Source configWarningSettings="0" name="mvTestSrc1" oms_version="2.66.1.0.0">
<SourceType>os_file</SourceType>
<TargetTypes>
<TargetType>omc_host_linux</TargetType>
</TargetTypes>
<DisplayName>mvTestSrc1</DisplayName>
<IsSystem>0</IsSystem>
<IsSecureContent>1</IsSecureContent>
<Patterns>
<Pattern>
<Value>/{SCHEMA2}/var/{SCHEMA1}/access_log11</Value>
<IsInclude>1</IsInclude>
<InUse>1</InUse>
<IsSystem>0</IsSystem>
<IsEnabled>1</IsEnabled>
</Pattern>
</Patterns>
<Parsers>
<Parser>
<ParserSeq>1</ParserSeq>
<ParserName>host_httpdaccesslog_logtype</ParserName>
</Parser>
</Parsers>
<MdFieldReferences>
<MdFieldReference key="#Backend Status Code">
<FieldName>udfi1</FieldName>
<IsSystem>0</IsSystem>
<IsEnabled>1</IsEnabled>
</MdFieldReference>
<MdFieldReference key="Access Mask">
<FieldName>accmask</FieldName>
<IsSystem>0</IsSystem>
<IsEnabled>1</IsEnabled>
</MdFieldReference>
</MdFieldReferences>
<TagConditions>
<TagCondition alertRuleVisible="0" field="method" operator="CONTAINS">
<ConditionValues>
<ConditionValue>select</ConditionValue>
</ConditionValues>
<ConditionTags tagField="mtag">
<ConditionTag>actnstart</ConditionTag>
</ConditionTags>
<IsSystem>0</IsSystem>
<IsEnabled>1</IsEnabled>
</TagCondition>
</TagConditions>
<SourceFunctions>
<SourceFunction lookupMode="0" name="Geolocation" order="101" overrideOutputFields="1">
<SourceInputFields>
<InputField lkCol="IP Field" order="1">method</InputField>
</SourceInputFields>
<SourceOutputFields>
<OutputField lkCol="Continent" order="1">continentclnt</OutputField>
<OutputField lkCol="Country Code" order="4">countrycodeclnt</OutputField>
<OutputField lkCol="Coordinates" order="8">geolocclnt</OutputField>
<OutputField lkCol="Continent Code" order="2">continentcodeclnt</OutputField>
<OutputField lkCol="City" order="7">cityclnt</OutputField>
<OutputField lkCol="Country" order="3">countryclnt</OutputField>
<OutputField lkCol="State Code" order="6">regioncodeclnt</OutputField>
<OutputField lkCol="State" order="5">regionclnt</OutputField>
</SourceOutputFields>
<SourceFunctionFeatures>
<FunctionFeature>
<Name>Geolocation</Name>
</FunctionFeature>
</SourceFunctionFeatures>
<IsSystem>0</IsSystem>
<IsEnabled>1</IsEnabled>
</SourceFunction>
</SourceFunctions>
<IsHidden>0</IsHidden>
<IsSMAEnabled>0</IsSMAEnabled>
<EventTypes>
<EventType>
<Name>test2</Name>
<SpecVersion>1.0</SpecVersion>
<IsEnabled>1</IsEnabled>
<IsSystem>0</IsSystem>
</EventType>
</EventTypes>
</Source>
<FieldNameMaps>
<FieldNameMap>
<Name>udfi1</Name>
<DisplayName>#Backend Status Code</DisplayName>
</FieldNameMap>
</FieldNameMaps>
</LoganContent>
29 changes: 29 additions & 0 deletions examples/logan_sources/contents/sources/Oracle Adv1/src12.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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">
<Source configWarningSettings="0" name="mvTestSrc2" oms_version="2.66.1.0.0">
<SourceType>os_file</SourceType>
<TargetTypes>
<TargetType>omc_host_linux</TargetType>
</TargetTypes>
<DisplayName>mvTestSrc2</DisplayName>
<IsSystem>0</IsSystem>
<IsSecureContent>1</IsSecureContent>
<Patterns>
<Pattern>
<Value>/{SCHEMA1}/var/{SCHEMA2}/tmp/access_log22</Value>
<IsInclude>1</IsInclude>
<InUse>1</InUse>
<IsSystem>0</IsSystem>
<IsEnabled>1</IsEnabled>
</Pattern>
</Patterns>
<Parsers>
<Parser>
<ParserSeq>1</ParserSeq>
<ParserName>host_httpdaccesslog_logtype</ParserName>
</Parser>
</Parsers>
<IsHidden>0</IsHidden>
<IsSMAEnabled>0</IsSMAEnabled>
</Source>
</LoganContent>
110 changes: 110 additions & 0 deletions examples/logan_sources/contents/sources/Oracle Asts1/src21.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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">
<Field oms_version="2.66.1.0.0">
<DisplayName>#Backend Status Code</DisplayName>
<Description>Shows a response code received from the backend</Description>
<FieldType>1</FieldType>
<IsSystem>0</IsSystem>
<IsPrimary>1</IsPrimary>
<DataType>INTEGER</DataType>
<IsMetricKeyEligible>0</IsMetricKeyEligible>
<IsMetricValueEligible>0</IsMetricValueEligible>
<FacetEligible>1</FacetEligible>
<RangeFacetEligible>0</RangeFacetEligible>
<TableEligible>1</TableEligible>
<FacetPriority>1</FacetPriority>
<Summarizable>1</Summarizable>
<HighCardinality>1</HighCardinality>
<LargeData>0</LargeData>
<MultiValued>0</MultiValued>
<SMAEnabledSetting>0</SMAEnabledSetting>
</Field>
<Source configWarningSettings="0" name="mvTestSrc1" oms_version="2.66.1.0.0">
<SourceType>os_file</SourceType>
<TargetTypes>
<TargetType>omc_host_linux</TargetType>
</TargetTypes>
<DisplayName>mvTestSrc1</DisplayName>
<IsSystem>0</IsSystem>
<IsSecureContent>1</IsSecureContent>
<Patterns>
<Pattern>
<Value>/{SCHEMA2}/var/{SCHEMA1}/access_log11</Value>
<IsInclude>1</IsInclude>
<InUse>1</InUse>
<IsSystem>0</IsSystem>
<IsEnabled>1</IsEnabled>
</Pattern>
</Patterns>
<Parsers>
<Parser>
<ParserSeq>1</ParserSeq>
<ParserName>host_httpdaccesslog_logtype</ParserName>
</Parser>
</Parsers>
<MdFieldReferences>
<MdFieldReference key="#Backend Status Code">
<FieldName>udfi1</FieldName>
<IsSystem>0</IsSystem>
<IsEnabled>1</IsEnabled>
</MdFieldReference>
<MdFieldReference key="Access Mask">
<FieldName>accmask</FieldName>
<IsSystem>0</IsSystem>
<IsEnabled>1</IsEnabled>
</MdFieldReference>
</MdFieldReferences>
<TagConditions>
<TagCondition alertRuleVisible="0" field="method" operator="CONTAINS">
<ConditionValues>
<ConditionValue>select</ConditionValue>
</ConditionValues>
<ConditionTags tagField="mtag">
<ConditionTag>actnstart</ConditionTag>
</ConditionTags>
<IsSystem>0</IsSystem>
<IsEnabled>1</IsEnabled>
</TagCondition>
</TagConditions>
<SourceFunctions>
<SourceFunction lookupMode="0" name="Geolocation" order="101" overrideOutputFields="1">
<SourceInputFields>
<InputField lkCol="IP Field" order="1">method</InputField>
</SourceInputFields>
<SourceOutputFields>
<OutputField lkCol="Continent" order="1">continentclnt</OutputField>
<OutputField lkCol="Country Code" order="4">countrycodeclnt</OutputField>
<OutputField lkCol="Coordinates" order="8">geolocclnt</OutputField>
<OutputField lkCol="Continent Code" order="2">continentcodeclnt</OutputField>
<OutputField lkCol="City" order="7">cityclnt</OutputField>
<OutputField lkCol="Country" order="3">countryclnt</OutputField>
<OutputField lkCol="State Code" order="6">regioncodeclnt</OutputField>
<OutputField lkCol="State" order="5">regionclnt</OutputField>
</SourceOutputFields>
<SourceFunctionFeatures>
<FunctionFeature>
<Name>Geolocation</Name>
</FunctionFeature>
</SourceFunctionFeatures>
<IsSystem>0</IsSystem>
<IsEnabled>1</IsEnabled>
</SourceFunction>
</SourceFunctions>
<IsHidden>0</IsHidden>
<IsSMAEnabled>0</IsSMAEnabled>
<EventTypes>
<EventType>
<Name>test2</Name>
<SpecVersion>1.0</SpecVersion>
<IsEnabled>1</IsEnabled>
<IsSystem>0</IsSystem>
</EventType>
</EventTypes>
</Source>
<FieldNameMaps>
<FieldNameMap>
<Name>udfi1</Name>
<DisplayName>#Backend Status Code</DisplayName>
</FieldNameMap>
</FieldNameMaps>
</LoganContent>
29 changes: 29 additions & 0 deletions examples/logan_sources/contents/sources/Oracle Asts1/src22.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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">
<Source configWarningSettings="0" name="mvTestSrc2" oms_version="2.66.1.0.0">
<SourceType>os_file</SourceType>
<TargetTypes>
<TargetType>omc_host_linux</TargetType>
</TargetTypes>
<DisplayName>mvTestSrc2</DisplayName>
<IsSystem>0</IsSystem>
<IsSecureContent>1</IsSecureContent>
<Patterns>
<Pattern>
<Value>/{SCHEMA1}/var/{SCHEMA2}/tmp/access_log22</Value>
<IsInclude>1</IsInclude>
<InUse>1</InUse>
<IsSystem>0</IsSystem>
<IsEnabled>1</IsEnabled>
</Pattern>
</Patterns>
<Parsers>
<Parser>
<ParserSeq>1</ParserSeq>
<ParserName>host_httpdaccesslog_logtype</ParserName>
</Parser>
</Parsers>
<IsHidden>0</IsHidden>
<IsSMAEnabled>0</IsSMAEnabled>
</Source>
</LoganContent>
9 changes: 9 additions & 0 deletions examples/logan_sources/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#Copyright (c) 2023 Oracle Corporation and/or its affiliates.
#Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl

module "logan_sources" {
source = "../../modules/logan_sources"
schema_names = var.schema_names
for_each = toset(split(",", var.products))
path = format("%s/%s", "./contents/sources", each.value)
}
22 changes: 22 additions & 0 deletions examples/logan_sources/provider.tf.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#Copyright (c) 2023 Oracle Corporation and/or its affiliates.
#Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl

provider "oci" {
region = "<region where custom content to be imported>"
fingerprint = ""
private_key_path = ""

tenancy_ocid = ""
user_ocid = ""

}

terraform {
required_providers {
oci = {
source = "oracle/oci"
version = ">= 4.67.3"
}
}
required_version = ">= 1.3.0"
}
8 changes: 8 additions & 0 deletions examples/logan_sources/terraform.tfvars.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#Copyright (c) 2023 Oracle Corporation and/or its affiliates.
#Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl

products="Oracle Adv1,Oracle Asts1"
schema_names={
"{SCHEMA1}" = "ABC"
"{SCHEMA2}" = "XYZ"
}
21 changes: 21 additions & 0 deletions examples/logan_sources/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (c) 2023, Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.

variable "config_file_profile" {
default = "DEFAULT"
}

variable "auth_type" {
default = "user"
}

variable "products" {
type = string
}

variable "schema_names" {
type = map
default = {
"abc" = "xyz"
}
}
Loading

0 comments on commit 5a00f7e

Please sign in to comment.