Skip to content

Commit

Permalink
* Minor edits
Browse files Browse the repository at this point in the history
  • Loading branch information
ag-ramachandran committed Jan 3, 2025
1 parent efb1e7d commit 80fb994
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 32 deletions.
6 changes: 0 additions & 6 deletions plugins/common/adx/adx_commons_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,13 @@ func TestWrite(t *testing.T) {
require.EqualError(t, errorInWrite, tC.expectedWriteError)
} else {
require.NoError(t, errorInWrite)

expectedNameOfMetric := tC.expected["metricName"].(string)

createdFakeIngestor := localFakeIngestor

require.Equal(t, expectedNameOfMetric, createdFakeIngestor.actualOutputMetric["name"])

expectedFields := tC.expected["fields"].(map[string]interface{})
require.Equal(t, expectedFields, createdFakeIngestor.actualOutputMetric["fields"])

expectedTags := tC.expected["tags"].(map[string]interface{})
require.Equal(t, expectedTags, createdFakeIngestor.actualOutputMetric["tags"])

expectedTime := tC.expected["timestamp"].(float64)
require.InDelta(t, expectedTime, createdFakeIngestor.actualOutputMetric["timestamp"], testutil.DefaultDelta)
}
Expand Down
28 changes: 14 additions & 14 deletions plugins/outputs/microsoft_fabric/microsoft_fabric.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ var sampleConfig string
type MicrosoftFabric struct {
ConnectionString string `toml:"connection_string"`
Log telegraf.Logger `toml:"-"`
ADXConf *adx_commons.AzureDataExplorer `toml:"adx_conf"`
EHConf *eh_commons.EventHubs `toml:"eh_conf"`
EventHouseConf *adx_commons.AzureDataExplorer `toml:"eh_conf"`
EventStreamConf *eh_commons.EventHubs `toml:"es_conf"`
FabricSinkService telegraf.Output
}

Expand Down Expand Up @@ -50,7 +50,7 @@ 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 EventHouse 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 Eventhouse 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")
}

if strings.HasPrefix(ConnectionString, "Endpoint=sb") {
Expand All @@ -61,18 +61,18 @@ func (m *MicrosoftFabric) Init() error {
TimestampUnits: config.Duration(time.Nanosecond),
TimestampFormat: time.RFC3339Nano,
}
m.EHConf.ConnectionString = ConnectionString
m.EHConf.Log = m.Log
m.EHConf.SetSerializer(serializer)
m.EHConf.Init()
m.FabricSinkService = m.EHConf
m.EventStreamConf.ConnectionString = ConnectionString
m.EventStreamConf.Log = m.Log
m.EventStreamConf.SetSerializer(serializer)
m.EventStreamConf.Init()
m.FabricSinkService = m.EventStreamConf
} 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
m.EventHouseConf.Endpoint = ConnectionString
m.EventHouseConf.Log = m.Log
m.EventHouseConf.Init()
m.FabricSinkService = m.EventHouseConf
} else {
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")
}
Expand Down Expand Up @@ -100,12 +100,12 @@ func init() {

outputs.Add("microsoft_fabric", func() telegraf.Output {
return &MicrosoftFabric{
ADXConf: &adx_commons.AzureDataExplorer{
EventHouseConf: &adx_commons.AzureDataExplorer{
Timeout: config.Duration(20 * time.Second),
CreateTables: true,
AppName: "Fabric.Telegraf",
},
EHConf: &eh_commons.EventHubs{
EventStreamConf: &eh_commons.EventHubs{
Hub: &eh_commons.EventHub{},
Timeout: config.Duration(30 * time.Second),
},
Expand Down
4 changes: 2 additions & 2 deletions plugins/outputs/microsoft_fabric/microsoft_fabric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ func TestMicrosoftFabric_Init(t *testing.T) {
mf := &MicrosoftFabric{
ConnectionString: tt.connectionString,
Log: testutil.Logger{},
ADXConf: &adx_commons.AzureDataExplorer{},
EHConf: &eh_commons.EventHubs{
EventHouseConf: &adx_commons.AzureDataExplorer{},
EventStreamConf: &eh_commons.EventHubs{
Hub: &eh_commons.EventHub{},
Timeout: config.Duration(30 * time.Second),
},
Expand Down
20 changes: 10 additions & 10 deletions plugins/outputs/microsoft_fabric/sample.conf
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Sends metrics to Microsoft Fabric
[[outputs.microsoft_fabric]]
## The URI property of the Azure Data Explorer resource on Azure
## The URI property of the Eventhouse resource on Azure
## ex: connection_string = https://myadxresource.australiasoutheast.kusto.windows.net
connection_string = ""


[outputs.microsoft_fabric.adx_conf]
## The Azure Data Explorer database that the metrics will be ingested into.
[outputs.microsoft_fabric.eh_conf]
## The Eventhouse database that the metrics will be ingested into.
## The plugin will NOT generate this database automatically, it's expected that this database already exists before ingestion.
## ex: "exampledatabase"
database = ""

## Timeout for Azure Data Explorer operations
## Timeout for Eventhouse operations
# timeout = "20s"

## Type of metrics grouping used when pushing to Azure Data Explorer.
## Type of metrics grouping used when pushing to Eventhouse.
## Default is "TablePerMetric" for one table per different metric.
## For more information, please check the plugin README.
# metrics_grouping_type = "TablePerMetric"
Expand All @@ -32,9 +32,9 @@
## - queued -- queue up metrics data and process sequentially
# ingestion_type = "queued"

[outputs.microsoft_fabric.eh_conf]
## The full connection string to the Event Hub (required)
## The shared access key must have "Send" permissions on the target Event Hub.
[outputs.microsoft_fabric.es_conf]
## The full connection string to the Event stream (required)
## The shared access key must have "Send" permissions on the target Event stream.

## Client timeout (defaults to 30s)
# timeout = "30s"
Expand All @@ -46,9 +46,9 @@
# partition_key = ""

## Set the maximum batch message size in bytes
## The allowable size depends on the Event Hub tier
## The allowable size depends on the Event stream tier
## See: https://learn.microsoft.com/azure/event-hubs/event-hubs-quotas#basic-vs-standard-vs-premium-vs-dedicated-tiers
## Setting this to 0 means using the default size from the Azure Event Hubs Client library (1000000 bytes)
## Setting this to 0 means using the default size from the Azure Event streams Client library (1000000 bytes)
# max_message_size = 1000000

## Data format to output.
Expand Down

0 comments on commit 80fb994

Please sign in to comment.