Skip to main content

nominal_api_conjure/conjure/objects/ingest/api/
journal_json_opts.rs

1#[derive(
2    Debug,
3    Clone,
4    conjure_object::serde::Serialize,
5    conjure_object::serde::Deserialize,
6    PartialEq,
7    Eq,
8    PartialOrd,
9    Ord,
10    Hash
11)]
12#[serde(crate = "conjure_object::serde")]
13#[conjure_object::private::staged_builder::staged_builder]
14#[builder(crate = conjure_object::private::staged_builder, update, inline)]
15pub struct JournalJsonOpts {
16    #[builder(custom(type = super::IngestSource, convert = Box::new))]
17    #[serde(rename = "source")]
18    source: Box<super::IngestSource>,
19    #[builder(custom(type = super::DatasetIngestTarget, convert = Box::new))]
20    #[serde(rename = "target")]
21    target: Box<super::DatasetIngestTarget>,
22    #[builder(default, into)]
23    #[serde(rename = "channel", skip_serializing_if = "Option::is_none", default)]
24    channel: Option<String>,
25    #[builder(
26        default,
27        custom(
28            type = impl
29            Into<Option<super::JournalTimestampMetadata>>,
30            convert = |v|v.into().map(Box::new)
31        )
32    )]
33    #[serde(
34        rename = "timestampMetadata",
35        skip_serializing_if = "Option::is_none",
36        default
37    )]
38    timestamp_metadata: Option<Box<super::JournalTimestampMetadata>>,
39}
40impl JournalJsonOpts {
41    /// Constructs a new instance of the type.
42    #[inline]
43    pub fn new(source: super::IngestSource, target: super::DatasetIngestTarget) -> Self {
44        Self::builder().source(source).target(target).build()
45    }
46    #[inline]
47    pub fn source(&self) -> &super::IngestSource {
48        &*self.source
49    }
50    #[inline]
51    pub fn target(&self) -> &super::DatasetIngestTarget {
52        &*self.target
53    }
54    /// If provided, ingests logs to the given channel.
55    /// By default, log data will be ingested to a channel named 'logs'.
56    #[inline]
57    pub fn channel(&self) -> Option<&str> {
58        self.channel.as_ref().map(|o| &**o)
59    }
60    /// Optional timestamp field for the JSON lines. When provided, each line is timestamped from this
61    /// field instead of the journald default `__REALTIME_TIMESTAMP`, allowing non-journald JSON logs to
62    /// ingest. Each line must still contain a `MESSAGE` field. Only numeric epoch timestamps are supported.
63    /// When absent, the journald default (`__REALTIME_TIMESTAMP`, microseconds) is used.
64    #[inline]
65    pub fn timestamp_metadata(&self) -> Option<&super::JournalTimestampMetadata> {
66        self.timestamp_metadata.as_ref().map(|o| &**o)
67    }
68}