Skip to content

Commit

Permalink
added adx prefixes support
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhishek-saharn committed Oct 18, 2024
1 parent 553e353 commit 88133d0
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions plugins/outputs/microsoft_fabric/microsoft_fabric.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,46 @@ func (m *MicrosoftFabric) Init() error {
ConnectionString := m.ConnectionString

if ConnectionString == "" {
return errors.New("endpoint must not be empty. For Kusto refer : https://learn.microsoft.com/kusto/api/connection-strings/kusto?view=microsoft-fabric for EventStream refer : https://learn.microsoft.com/fabric/real-time-intelligence/event-streams/add-manage-eventstream-sources?pivots=enhanced-capabilities")
return errors.New("endpoint must not be empty. For Kusto refer : https://learn.microsoft.com/kusto/api/connection-strings/kusto?view=microsoft-fabric for EventHouse refer : https://learn.microsoft.com/fabric/real-time-intelligence/event-streams/add-manage-eventstream-sources?pivots=enhanced-capabilities")
}

if strings.HasPrefix(ConnectionString, "Endpoint=sb") {
m.Log.Info("Detected EventHub endpoint, using EventHub output plugin")
m.Log.Info("Detected EventHouse endpoint, using EventHouse output plugin")
m.EHConf.ConnectionString = ConnectionString
m.EHConf.Log = m.Log
m.EHConf.Init()
m.FabricSinkService = m.EHConf
} else if strings.HasPrefix(ConnectionString, "https://") {
} else if isKustoEndpoint(strings.ToLower(ConnectionString)) {
m.Log.Info("Detected Kusto endpoint, using Kusto output plugin")
//Setting up the AzureDataExplorer plugin initial properties
m.ADXConf.Endpoint = ConnectionString
m.ADXConf.Log = m.Log
m.ADXConf.Init()
m.FabricSinkService = m.ADXConf
} else {
return errors.New("invalid connection string. Connection string must start with 'Endpoint=sb' for EventHub or 'https://' for Kusto")
return errors.New("invalid connection string. For Kusto refer : https://learn.microsoft.com/kusto/api/connection-strings/kusto?view=microsoft-fabric for EventHouse refer : https://learn.microsoft.com/fabric/real-time-intelligence/event-streams/add-manage-eventstream-sources?pivots=enhanced-capabilities")
}
return nil
}

func isKustoEndpoint(endpoint string) bool {
prefixes := []string{
"https://",
"data source=",
"addr=",
"address=",
"network address=",
"server=",
}

for _, prefix := range prefixes {
if strings.HasPrefix(endpoint, prefix) {
return true
}
}
return false
}

func init() {

outputs.Add("microsoft_fabric", func() telegraf.Output {
Expand Down

0 comments on commit 88133d0

Please sign in to comment.