// In your own Cargo.toml, add the dependencies `serde_json` and `tokio`. // See this crate's Cargo.toml for the versions of these dependencies which // are currently used in `simple_azure_monitor_data_collector`. use serde_json::json; use simple_azure_monitor_data_collector::{LogClient, Records}; #[tokio::main] async fn main() -> Result<(), Box> { // The data we want to send: let json_records = json!( [ { "exampleRecordId": 1, "message": "Hello", }, { "exampleRecordId": 2, "message": "World", }, ] ); // Create a `Records` struct to hold the data and additional info: let log_type = "BasicExampleLog".to_string(); let azure_resource_id = None; let time_generated_field = None; let records = Records::new( log_type, json_records, azure_resource_id, time_generated_field, )?; // Create a client to send log records: let api_version = "2016-04-01".to_string(); let workspace_id = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX".to_string(); let key = "aohashxntoahuhaoensuhoanthxshpchu/chatohesxh==".to_string(); // your key for the workspace let timeout_in_seconds = 60; let log_client = LogClient::new(api_version, workspace_id, key, timeout_in_seconds)?; // Send the records: log_client.log(records).await?; Ok(()) }