Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions source/code/go/src/plugins/oms.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ var (
Computer string
// WorkspaceID log analytics workspace id
WorkspaceID string
// ResourceID for resource-centric log analytics data
ResourceID string
// Resource-centric flag (will be true if we determine if above RseourceID is non-empty - default is false)
ResourceCentric bool
)

var (
Expand Down Expand Up @@ -294,6 +298,10 @@ func PostDataHelper(tailPluginRecords []map[interface{}]interface{}) int {
}
req, _ := http.NewRequest("POST", OMSEndpoint, bytes.NewBuffer(marshalled))
req.Header.Set("Content-Type", "application/json")
//expensive to do string len for every request, so use a flag
if ResourceCentric == true {
req.Header.Set("x-ms-AzureResourceId", ResourceID)
}

resp, err := HTTPClient.Do(req)
elapsed := time.Since(start)
Expand Down Expand Up @@ -377,6 +385,11 @@ func InitializePlugin(pluginConfPath string, agentVersion string) {
}
OMSEndpoint = omsadminConf["OMS_ENDPOINT"]
WorkspaceID = omsadminConf["WORKSPACE_ID"]
ResourceID = os.Getenv("customResourceId")
if len(ResourceID) > 0 {
ResourceCentric = true
Log("OMS ResourceId=%s",ResourceID)
}
Log("OMSEndpoint %s", OMSEndpoint)

// Initialize image,name map refresh ticker
Expand Down