-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from iLert/feature/metrics
Feature/metrics
- Loading branch information
Showing
10 changed files
with
817 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/iLert/ilert-go/v2" | ||
) | ||
|
||
func main() { | ||
var apiToken = "your API token" | ||
client := ilert.NewClient(ilert.WithAPIToken(apiToken)) | ||
|
||
createMetricInput := &ilert.CreateMetricInput{ | ||
Metric: &ilert.Metric{ | ||
Name: "example", | ||
AggregationType: ilert.MetricAggregationType.Average, | ||
DisplayType: ilert.MetricDisplayType.Graph, | ||
Metadata: &ilert.MetricProviderMetadata{ | ||
Query: "your prometheus query", | ||
}, | ||
DataSource: &ilert.MetricDataSource{ | ||
ID: 0, // your metric data source id | ||
}, | ||
}, | ||
} | ||
|
||
result, err := client.CreateMetric(createMetricInput) | ||
if err != nil { | ||
log.Println(result) | ||
log.Fatalln("ERROR:", err) | ||
} | ||
log.Printf("Metric:\n\n %+v\n", result.Metric) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/iLert/ilert-go/v2" | ||
) | ||
|
||
func main() { | ||
var apiToken = "your API token" | ||
client := ilert.NewClient(ilert.WithAPIToken(apiToken)) | ||
|
||
createDataSourceInput := &ilert.CreateMetricDataSourceInput{ | ||
MetricDataSource: &ilert.MetricDataSource{ | ||
Name: "example", | ||
Type: ilert.MetricDataSourceType.Prometheus, | ||
Metadata: &ilert.MetricDataSourceMetadata{ | ||
AuthType: ilert.MetricDataSourceAuthType.Basic, | ||
BasicUser: "your prometheus username", | ||
BasicPass: "your prometheus password", | ||
Url: "your prometheus url", | ||
}, | ||
}, | ||
} | ||
|
||
result, err := client.CreateMetricDataSource(createDataSourceInput) | ||
if err != nil { | ||
log.Println(result) | ||
log.Fatalln("ERROR:", err) | ||
} | ||
log.Printf("Metric Data Source:\n\n %+v\n", result.MetricDataSource) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/iLert/ilert-go/v2" | ||
) | ||
|
||
func main() { | ||
var apiToken = "your API token" | ||
client := ilert.NewClient(ilert.WithAPIToken(apiToken)) | ||
|
||
createSingleSeriesInput := &ilert.CreateSingleSeriesInput{ | ||
Series: &ilert.SingleSeries{ | ||
Value: 500, | ||
}, | ||
MetricKey: ilert.String("your metric integration key"), | ||
} | ||
|
||
err := client.CreateSingleSeries(createSingleSeriesInput) | ||
if err != nil { | ||
log.Fatalln("ERROR:", err) | ||
} else { | ||
log.Println("Series submitted successfully") | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.