influxdb-0.0.0: Haskell client library for InfluxDB

Safe HaskellNone

Database.InfluxDB

Contents

Synopsis

Series data types

data Series Source

A series consists of name, columns and points. The columns and points are expressed in a separate type SeriesData.

Constructors

Series 

Fields

seriesName :: !Text

Series name

seriesData :: !SeriesData

Columns and data points in the series

seriesColumns :: Series -> Vector ColumnSource

Convenient accessor for columns.

seriesPoints :: Series -> DList (Vector Value)Source

Convenient accessor for points.

data SeriesData Source

SeriesData consists of columns and points.

data Value Source

An InfluxDB value represented as a Haskell value.

Constructors

Int !Int64 
Float !Double 
String !Text 
Bool !Bool 
Null 

Encoding

class ToSeriesData a whereSource

A type that can be converted to a SeriesData. A typical implementation is as follows.

 import qualified Data.Vector as V

 data Event = Event Text EventType
 data EventType = Login | Logout

 instance ToSeriesData where
   toSeriesColumn _ = V.fromList ["user", "type"]
   toSeriesPoints (Event user ty) = V.fromList [toValue user, toValue ty]

 instance ToValue EventType

Methods

toSeriesColumns :: Proxy a -> Vector ColumnSource

Column names. You can safely ignore the proxy agument.

toSeriesPoints :: a -> Vector ValueSource

Data points.

Decoding

class FromSeries a whereSource

A type that can be converted from a Series.

fromSeries :: FromSeries a => Series -> Either String aSource

Converte a value from a Series, failing if the types do not match.

class FromSeriesData a whereSource

A type that can be converted from a SeriesData. A typical implementation is as follows.

 import Control.Applicative ((<$>), (<*>))
 import qualified Data.Vector as V

 data Event = Event Text EventType
 data EventType = Login | Logout

 instance FromSeriesData where
   parseSeriesData = withValues $ values -> Event
     <$> values .: "user"
     <*> values .: "type"

 instance FromValue EventType

fromSeriesData :: FromSeriesData a => SeriesData -> Either String [a]Source

Converte a value from a SeriesData, failing if the types do not match.

class FromValue a whereSource

A type that can be converted from a Value.

fromValue :: FromValue a => Value -> Either String aSource

Converte a value from a Value, failing if the types do not match.

HTTP API

Data types

data Config Source

Configurations for HTTP API client.

data Credentials Source

User credentials.

Constructors

Credentials 

Fields

credsUser :: !Text
 
credsPassword :: !Text
 

Instances

rootCreds :: CredentialsSource

Default credentials.

data Server Source

Server location.

Constructors

Server 

Fields

serverHost :: !Text

Hostname or IP address

serverPort :: !Int
 
serverSsl :: !Bool

SSL is enabled or not in the server side

Instances

localServer :: ServerSource

Default server location.

data ServerPool Source

Non-empty set of server locations. The active server will always be used until any HTTP communications fail.

newServerPool :: Server -> [Server] -> IO (IORef ServerPool)Source

Create a non-empty server pool. You must specify at least one server location to create a pool.

data Database Source

Database consits of name and replication factor.

newtype User Source

User

Constructors

User 

Fields

userName :: Text
 

Instances

newtype Admin Source

Administrator

Constructors

Admin 

Fields

adminUsername :: Text
 

Instances

Writing Data

Updating Points

post :: Config -> Manager -> Database -> SeriesT IO a -> IO aSource

Post a bunch of writes for (possibly multiple) series into a database.

postWithPrecision :: Config -> Manager -> Database -> TimePrecision -> SeriesT IO a -> IO aSource

Post a bunch of writes for (possibly multiple) series into a database like post but with time precision.

data SeriesT m a Source

Monad transformer to batch up multiple writes of series to speed up insertions.

data PointT p m a Source

Monad transformer to batch up multiple writes of points to speed up insertions.

Instances

writeSeriesSource

Arguments

:: (Monad m, ToSeriesData a) 
=> Text

Series name

-> a

Series data

-> SeriesT m () 

Write a single series data.

withSeriesSource

Arguments

:: forall m a . (Monad m, ToSeriesData a) 
=> Text

Series name

-> PointT a m () 
-> SeriesT m () 

Write a bunch of data for a single series. Columns for the points don't need to be specified because they can be inferred from the type of a.

writePoints :: (Monad m, ToSeriesData a) => a -> PointT a m ()Source

Write a data into a series.

Deleting Points

One Time Deletes (not implemented)

Regularly Scheduled Deletes (not implemented)

Querying Data

querySource

Arguments

:: FromSeries a 
=> Config 
-> Manager 
-> Database 
-> Text

Query text

-> IO [a] 

Query a specified database.

The query format is specified in the InfluxDB Query Language.

data Stream m a Source

Effectful stream

Constructors

Yield a (m (Stream m a))

Yield a value. The stream will be continued.

Done

The end of the stream.

queryChunkedSource

Arguments

:: FromSeries a 
=> Config 
-> Manager 
-> Database 
-> Text

Query text

-> (Stream IO a -> IO b)

Action to handle the resulting stream of series

-> IO b 

Query a specified database like query but in a streaming fashion.

Administration & Security

Creating and Dropping Databases

listDatabases :: Config -> Manager -> IO [Database]Source

List existing databases.

createDatabase :: Config -> Manager -> Text -> IO DatabaseSource

Create a new database. Requires cluster admin privileges.

dropDatabase :: Config -> Manager -> Database -> IO ()Source

Drop a database. Requires cluster admin privileges.

Security

Cluster admin

listClusterAdmins :: Config -> Manager -> IO [Admin]Source

List cluster administrators.

addClusterAdmin :: Config -> Manager -> Text -> IO AdminSource

Add a new cluster administrator. Requires cluster admin privilege.

updateClusterAdminPassword :: Config -> Manager -> Admin -> Text -> IO ()Source

Update a cluster administrator's password. Requires cluster admin privilege.

deleteClusterAdmin :: Config -> Manager -> Admin -> IO ()Source

Delete a cluster administrator. Requires cluster admin privilege.

Database user

listDatabaseUsers :: Config -> Manager -> Text -> IO [User]Source

List database users.

addDatabaseUser :: Config -> Manager -> Database -> Text -> IO UserSource

Add an user to the database users.

updateDatabaseUserPassword :: Config -> Manager -> Database -> User -> Text -> IO ()Source

Update password for the database user.

deleteDatabaseUser :: Config -> Manager -> Database -> User -> IO ()Source

Delete an user from the database users.

grantAdminPrivilegeTo :: Config -> Manager -> Database -> User -> IO ()Source

Give admin privilege to the user.

revokeAdminPrivilegeFrom :: Config -> Manager -> Database -> User -> IO ()Source

Remove admin privilege from the user.