Safe Haskell | None |
---|---|
Language | Haskell2010 |
Database.InfluxDB.Line
Synopsis
- data Line time = Line !Measurement !(Map Key Key) !(Map Key LineField) !(Maybe time)
- measurement :: forall time f. Functor f => (Measurement -> f Measurement) -> Line time -> f (Line time)
- tagSet :: forall time f. Functor f => (Map Key Key -> f (Map Key Key)) -> Line time -> f (Line time)
- fieldSet :: forall time f. Functor f => (Map Key LineField -> f (Map Key LineField)) -> Line time -> f (Line time)
- timestamp :: forall time f. Functor f => (Maybe time -> f (Maybe time)) -> Line time -> f (Line time)
- buildLine :: (time -> Int64) -> Line time -> Builder
- buildLines :: Foldable f => (time -> Int64) -> f (Line time) -> Builder
- encodeLine :: (time -> Int64) -> Line time -> ByteString
- encodeLines :: Foldable f => (time -> Int64) -> f (Line time) -> ByteString
- type LineField = Field 'NonNullable
- data Field (n :: Nullability) where
- FieldInt :: forall (n :: Nullability). !Int64 -> Field n
- FieldFloat :: forall (n :: Nullability). !Double -> Field n
- FieldString :: forall (n :: Nullability). !Text -> Field n
- FieldBool :: forall (n :: Nullability). !Bool -> Field n
- FieldNull :: Field 'Nullable
- data Precision (ty :: RequestType) where
- Nanosecond :: forall (ty :: RequestType). Precision ty
- Microsecond :: forall (ty :: RequestType). Precision ty
- Millisecond :: forall (ty :: RequestType). Precision ty
- Second :: forall (ty :: RequestType). Precision ty
- Minute :: forall (ty :: RequestType). Precision ty
- Hour :: forall (ty :: RequestType). Precision ty
- RFC3339 :: Precision 'QueryRequest
Documentation
The Line protocol implementation.
>>>
:set -XOverloadedStrings
>>>
import Data.Time
>>>
import Database.InfluxDB.Line
>>>
import System.IO (stdout)
>>>
import qualified Data.ByteString as B
>>>
import qualified Data.ByteString.Builder as B
>>>
import qualified Data.ByteString.Lazy.Char8 as BL8
>>>
:{
let l1 = Line "cpu_usage" (Map.singleton "cpu" "cpu-total") (Map.fromList [ ("idle", FieldFloat 10.1) , ("system", FieldFloat 53.3) , ("user", FieldFloat 46.6) ]) (Just $ parseTimeOrError False defaultTimeLocale "%F %T%Q %Z" "2017-06-17 15:41:40.42659044 UTC") :: Line UTCTime :}
Types and accessors
Placeholder for the Line Protocol
See https://docs.influxdata.com/influxdb/v1.7/write_protocols/line_protocol_tutorial/ for the concrete syntax.
measurement :: forall time f. Functor f => (Measurement -> f Measurement) -> Line time -> f (Line time) Source #
Name of the measurement that you want to write your data to.
tagSet :: forall time f. Functor f => (Map Key Key -> f (Map Key Key)) -> Line time -> f (Line time) Source #
Tag(s) that you want to include with your data point. Tags are optional in
the Line Protocol, so you can set it empty
.
fieldSet :: forall time f. Functor f => (Map Key LineField -> f (Map Key LineField)) -> Line time -> f (Line time) Source #
Field(s) for your data point. Every data point requires at least one field
in the Line Protocol, so it shouldn't be empty
.
timestamp :: forall time f. Functor f => (Maybe time -> f (Maybe time)) -> Line time -> f (Line time) Source #
Timestamp for your data point. You can put whatever type of timestamp that
is an instance of the Timestamp
class.
Serializers
Arguments
:: (time -> Int64) | Function to convert time to an InfluxDB timestamp |
-> Line time | |
-> ByteString |
Serialize a Line
to a lazy bytestring
>>>
BL8.putStrLn $ encodeLine (scaleTo Second) l1
cpu_usage,cpu=cpu-total idle=10.1,system=53.3,user=46.6 1497714100
Arguments
:: Foldable f | |
=> (time -> Int64) | Function to convert time to an InfluxDB timestamp |
-> f (Line time) | |
-> ByteString |
Serialize Line
s to a lazy bytestring
>>>
BL8.putStr $ encodeLines (scaleTo Second) [l1, l1]
cpu_usage,cpu=cpu-total idle=10.1,system=53.3,user=46.6 1497714100 cpu_usage,cpu=cpu-total idle=10.1,system=53.3,user=46.6 1497714100
Other types
type LineField = Field 'NonNullable Source #
Field type for the line protocol. The line protocol doesn't accept null values.
data Field (n :: Nullability) where Source #
Constructors
FieldInt :: forall (n :: Nullability). !Int64 -> Field n | Signed 64-bit integers ( |
FieldFloat :: forall (n :: Nullability). !Double -> Field n | IEEE-754 64-bit floating-point numbers. This is the default numerical type. |
FieldString :: forall (n :: Nullability). !Text -> Field n | String field. Its length is limited to 64KB, which is not enforced by this library. |
FieldBool :: forall (n :: Nullability). !Bool -> Field n | Boolean field. |
FieldNull :: Field 'Nullable | Null field. Note that a field can be null only in queries. The line protocol doesn't allow null values. |
data Precision (ty :: RequestType) where Source #
Predefined set of time precision.
RFC3339
is only available for QueryRequest
s.
Constructors
Nanosecond :: forall (ty :: RequestType). Precision ty | POSIX time in ns |
Microsecond :: forall (ty :: RequestType). Precision ty | POSIX time in μs |
Millisecond :: forall (ty :: RequestType). Precision ty | POSIX time in ms |
Second :: forall (ty :: RequestType). Precision ty | POSIX time in s |
Minute :: forall (ty :: RequestType). Precision ty | POSIX time in minutes |
Hour :: forall (ty :: RequestType). Precision ty | POSIX time in hours |
RFC3339 :: Precision 'QueryRequest | Nanosecond precision time in a human readable format, like
|