Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data Query
- manage :: QueryParams -> Query -> IO ()
- data QueryParams
- queryParams :: Database -> QueryParams
- server :: HasServer a => Lens' a Server
- database :: HasDatabase a => Lens' a Database
- precision :: HasPrecision ty a => Lens' a (Precision ty)
- manager :: HasManager a => Lens' a (Either ManagerSettings Manager)
- data ShowQuery
- qid :: Lens' ShowQuery Int
- queryText :: Lens' ShowQuery Query
- duration :: Lens' ShowQuery NominalDiffTime
- data ShowSeries
- key :: Lens' ShowSeries Key
Management query interface
An InfluxDB query.
A spec of the format is available at https://docs.influxdata.com/influxdb/v1.2/query_language/spec/.
A Query
can be constructed using either
- the
IsString
instance with-XOverloadedStrings
- or
formatQuery
.
>>>
:set -XOverloadedStrings
>>>
"SELECT * FROM series" :: Query
"SELECT * FROM series">>>
import qualified Database.InfluxDB.Format as F
>>>
formatQuery ("SELECT * FROM "%F.key) "series"
"SELECT * FROM \"series\""
NOTE: Currently this library doesn't support type-safe query construction.
manage :: QueryParams -> Query -> IO () Source #
Send a database management query to InfluxDB.
>>>
let db = "manage-test"
>>>
let p = queryParams db
>>>
manage p $ F.formatQuery ("CREATE DATABASE "%F.database) db
Query parameters
data QueryParams Source #
The full set of parameters for the query API
HasCredentials QueryParams Source # | Authentication info for the query
|
HasManager QueryParams Source # |
|
HasDatabase QueryParams Source # |
|
HasServer QueryParams Source # |
|
HasPrecision QueryRequest QueryParams Source # | Returning JSON responses contain timestamps in the specified precision/format.
|
queryParams :: Database -> QueryParams Source #
Smart constructor for QueryParams
Default parameters:
server :: HasServer a => Lens' a Server Source #
InfluxDB server address and port that to interact with.
manager :: HasManager a => Lens' a (Either ManagerSettings Manager) Source #
HTTP manager settings or a manager itself.
If it's set to ManagerSettings
, the library will create a Manager
from
the settings for you.
Management query results
SHOW QUERIES
>>>
v <- query (queryParams "_internal") "SHOW QUERIES" :: IO (V.Vector ShowQuery)
HasDatabase ShowQuery Source # | > v <- query (queryParams "_internal") "SHOW QUERIES" :: IO (V.Vector ShowQuery) > v ^.. each.database ["_internal"] |
QueryResults ShowQuery Source # | |
qid :: Lens' ShowQuery Int Source #
Query ID
> v <- query (queryParams "_internal") "SHOW QUERIES" :: IO (V.Vector ShowQuery) > v ^.. each.qid [149250]
queryText :: Lens' ShowQuery Query Source #
Query text
> v <- query (queryParams "_internal") "SHOW QUERIES" :: IO (V.Vector ShowQuery) > v ^.. each.queryText ["SHOW QUERIES"]
duration :: Lens' ShowQuery NominalDiffTime Source #
Duration of the query
> v <- query (queryParams "_internal") "SHOW QUERIES" :: IO (V.Vector ShowQuery) > v ^.. each.duration [0.06062s]