Safe Haskell | None |
---|---|
Language | Haskell2010 |
This is an internal module. No guarantees are made in this module about API stability.
- data EsScribeCfg v = EsScribeCfg {
- essRetryPolicy :: RetryPolicy
- essQueueSize :: EsQueueSize
- essPoolSize :: EsPoolSize
- essAnnotateTypes :: Bool
- essIndexSettings :: IndexSettings v
- essIndexSharding :: IndexShardingPolicy
- defaultEsScribeCfg' :: ESVersion v => proxy v -> EsScribeCfg v
- defaultEsScribeCfg :: EsScribeCfg ESV1
- defaultEsScribeCfgV1 :: EsScribeCfg ESV1
- defaultEsScribeCfgV5 :: EsScribeCfg ESV5
- data IndexShardingPolicy
- = NoIndexSharding
- | MonthlyIndexSharding
- | WeeklyIndexSharding
- | DailyIndexSharding
- | HourlyIndexSharding
- | EveryMinuteIndexSharding
- | CustomIndexSharding (forall a. Item a -> [IndexNameSegment])
- newtype IndexNameSegment = IndexNameSegment {
- indexNameSegment :: Text
- shardPolicySegs :: IndexShardingPolicy -> Item a -> [IndexNameSegment]
- roundToSunday :: Day -> Day
- chooseIxn :: ESVersion v => proxy v -> IndexName v -> IndexShardingPolicy -> Item a -> IndexName v
- sis :: Integral a => a -> IndexNameSegment
- splitTime :: DiffTime -> (Int, Int)
- data EsScribeSetupError
- = CouldNotCreateIndex !(Response ByteString)
- | CouldNotCreateMapping !(Response ByteString)
- mkEsScribe :: forall v. (ESVersion v, MonadIO (BH v IO), Functor (BH v IO)) => EsScribeCfg v -> BHEnv v -> IndexName v -> MappingName v -> Severity -> Verbosity -> IO Scribe
- baseMapping :: ESVersion v => proxy v -> MappingName v -> Value
- esDateFormat :: Text
- mkDocId :: ESVersion v => proxy v -> IO (DocId v)
- newtype EsQueueSize = EsQueueSize {
- unEsQueueSize :: Int
- mkEsQueueSize :: Int -> Maybe EsQueueSize
- newtype EsPoolSize = EsPoolSize {
- unEsPoolSize :: Int
- mkEsPoolSize :: Int -> Maybe EsPoolSize
- mkNonZero :: (Int -> a) -> Int -> Maybe a
- startWorker :: forall v. ESVersion v => EsScribeCfg v -> BHEnv v -> MappingName v -> TBMQueue (IndexName v, Value) -> IO ()
- class ESVersion v where
- type BHEnv v
- type IndexSettings v
- type IndexName v
- type MappingName v
- type DocId v
- type BH v :: (* -> *) -> * -> *
- type TemplateName v
- type TemplatePattern v
- type IndexTemplate v
- type IndexDocumentSettings v
- defaultIndexSettings :: proxy v -> IndexSettings v
- toIndexName :: proxy v -> Text -> IndexName v
- fromIndexName :: proxy v -> IndexName v -> Text
- fromMappingName :: proxy v -> MappingName v -> Text
- toDocId :: proxy v -> Text -> DocId v
- runBH :: proxy v -> BHEnv v -> BH v m a -> m a
- toTemplateName :: proxy v -> Text -> TemplateName v
- toTemplatePattern :: proxy v -> Text -> TemplatePattern v
- toIndexTemplate :: proxy v -> TemplatePattern v -> Maybe (IndexSettings v) -> [Value] -> IndexTemplate v
- defaultIndexDocumentSettings :: proxy v -> IndexDocumentSettings v
- indexExists :: proxy v -> IndexName v -> BH v IO Bool
- indexDocument :: ToJSON doc => proxy v -> IndexName v -> MappingName v -> IndexDocumentSettings v -> doc -> DocId v -> BH v IO (Response ByteString)
- createIndex :: proxy v -> IndexSettings v -> IndexName v -> BH v IO (Response ByteString)
- putTemplate :: proxy v -> IndexTemplate v -> TemplateName v -> BH v IO (Response ByteString)
- putMapping :: ToJSON a => proxy v -> IndexName v -> MappingName v -> a -> BH v IO (Response ByteString)
- data ESV1 = ESV1
- data ESV5 = ESV5
Documentation
data EsScribeCfg v Source
EsScribeCfg now carries a type variable for the version of
ElasticSearch it targets, either ESV1
or ESV5
. You can use
defaultEsScribeCfgV1
and defaultESScribeCfgV5
for a good
starting point depending on the ES version you have.
EsScribeCfg | |
|
defaultEsScribeCfg' :: ESVersion v => proxy v -> EsScribeCfg v Source
Reasonable defaults for a config:
- defaultManagerSettings
- exponential backoff with 25ms base delay up to 5 retries
- Queue size of 1000
- Pool size of 2
- Annotate types set to False
- DailyIndexSharding
defaultEsScribeCfg :: EsScribeCfg ESV1 Source
Alias of defaultEsScribeCfgV1
to minimize API
breakage. Previous versions of katip-elasticsearch only supported
ES version 1.
defaultEsScribeCfgV1 :: EsScribeCfg ESV1 Source
EsScribeCfg that will use ElasticSearch V1
defaultEsScribeCfgV5 :: EsScribeCfg ESV5 Source
EsScribeCfg that will use ElasticSearch V5
data IndexShardingPolicy Source
How should katip store your log data?
- NoIndexSharding will store all logs in one index name. This is the simplest option but is not advised in production. In practice, the index will grow very large and will get slower to search. Deleting records based on some sort of retention period is also extremely slow.
- MonthlyIndexSharding, DailyIndexSharding, HourlyIndexSharding,
EveryMinuteIndexSharding will generate indexes based on the time of
the log. Index name is treated as a prefix. So if your index name
is
foo
and DailySharding is used, logs will be stored infoo-2016-2-25
,foo-2016-2-26
and so on. Index templating will be used to set up mappings automatically. Deletes based on date are very fast and queries can be restricted to date ranges for better performance. Queries against all dates should usefoo-*
as an index name. Note that index aliasing's glob feature is not suitable for these date ranges as it matches index names as they are declared, so new dates will be excluded. DailyIndexSharding is a reasonable choice. Changing index sharding strategies is not advisable. - CustomSharding: supply your own function that decomposes an item
into its index name hierarchy which will be appended to the index
name. So for instance if your function return ["arbitrary",
"prefix"], the index will be
foo-arbitrary-prefix
and the index template will be set to matchfoo-*
. In general, you want to use segments of increasing granularity (like year, month, day for dates). This makes it easier to address groups of indexes (e.g.foo-2016-*
).
NoIndexSharding | |
MonthlyIndexSharding | |
WeeklyIndexSharding | A special case of daily which shards to sunday |
DailyIndexSharding | |
HourlyIndexSharding | |
EveryMinuteIndexSharding | |
CustomIndexSharding (forall a. Item a -> [IndexNameSegment]) |
newtype IndexNameSegment Source
IndexNameSegment | |
|
shardPolicySegs :: IndexShardingPolicy -> Item a -> [IndexNameSegment] Source
roundToSunday :: Day -> Day Source
If the given day is sunday, returns the input, otherwise returns the previous sunday
chooseIxn :: ESVersion v => proxy v -> IndexName v -> IndexShardingPolicy -> Item a -> IndexName v Source
sis :: Integral a => a -> IndexNameSegment Source
data EsScribeSetupError Source
CouldNotCreateIndex !(Response ByteString) | |
CouldNotCreateMapping !(Response ByteString) |
:: (ESVersion v, MonadIO (BH v IO), Functor (BH v IO)) | |
=> EsScribeCfg v | |
-> BHEnv v | |
-> IndexName v | Treated as a prefix if index sharding is enabled |
-> MappingName v | |
-> Severity | |
-> Verbosity | |
-> IO Scribe |
The Any field tagged with a v
corresponds to the type of the
same name in the corresponding bloodhound
module. For instance,
if you are configuring for ElasticSearch version 1, import
Database.V1.Bloodhound
and BHEnv v
will refer to BHEnv
from
that module, IndexName v
will repsond to IndexName
from that
module, etc.
baseMapping :: ESVersion v => proxy v -> MappingName v -> Value Source
esDateFormat :: Text Source
Handle both old-style aeson and picosecond-level precision
newtype EsQueueSize Source
mkEsQueueSize :: Int -> Maybe EsQueueSize Source
newtype EsPoolSize Source
mkEsPoolSize :: Int -> Maybe EsPoolSize Source
startWorker :: forall v. ESVersion v => EsScribeCfg v -> BHEnv v -> MappingName v -> TBMQueue (IndexName v, Value) -> IO () Source
class ESVersion v where Source
type IndexSettings v Source
type MappingName v Source
type BH v :: (* -> *) -> * -> * Source
type TemplateName v Source
type TemplatePattern v Source
type IndexTemplate v Source
type IndexDocumentSettings v Source
defaultIndexSettings :: proxy v -> IndexSettings v Source
toIndexName :: proxy v -> Text -> IndexName v Source
fromIndexName :: proxy v -> IndexName v -> Text Source
fromMappingName :: proxy v -> MappingName v -> Text Source
toDocId :: proxy v -> Text -> DocId v Source
runBH :: proxy v -> BHEnv v -> BH v m a -> m a Source
toTemplateName :: proxy v -> Text -> TemplateName v Source
toTemplatePattern :: proxy v -> Text -> TemplatePattern v Source
toIndexTemplate :: proxy v -> TemplatePattern v -> Maybe (IndexSettings v) -> [Value] -> IndexTemplate v Source
defaultIndexDocumentSettings :: proxy v -> IndexDocumentSettings v Source
indexExists :: proxy v -> IndexName v -> BH v IO Bool Source
indexDocument :: ToJSON doc => proxy v -> IndexName v -> MappingName v -> IndexDocumentSettings v -> doc -> DocId v -> BH v IO (Response ByteString) Source
createIndex :: proxy v -> IndexSettings v -> IndexName v -> BH v IO (Response ByteString) Source
putTemplate :: proxy v -> IndexTemplate v -> TemplateName v -> BH v IO (Response ByteString) Source
putMapping :: ToJSON a => proxy v -> IndexName v -> MappingName v -> a -> BH v IO (Response ByteString) Source
ESVersion ESV1 Source | |
type BHEnv ESV1 = BHEnv Source | |
type IndexSettings ESV1 = IndexSettings Source | |
type IndexName ESV1 = IndexName Source | |
type MappingName ESV1 = MappingName Source | |
type DocId ESV1 = DocId Source | |
type BH ESV1 = BH Source | |
type TemplateName ESV1 = TemplateName Source | |
type TemplatePattern ESV1 = TemplatePattern Source | |
type IndexTemplate ESV1 = IndexTemplate Source | |
type IndexDocumentSettings ESV1 = IndexDocumentSettings Source |
ESVersion ESV5 Source | |
type BHEnv ESV5 = BHEnv Source | |
type IndexSettings ESV5 = IndexSettings Source | |
type IndexName ESV5 = IndexName Source | |
type MappingName ESV5 = MappingName Source | |
type DocId ESV5 = DocId Source | |
type BH ESV5 = BH Source | |
type TemplateName ESV5 = TemplateName Source | |
type TemplatePattern ESV5 = TemplatePattern Source | |
type IndexTemplate ESV5 = IndexTemplate Source | |
type IndexDocumentSettings ESV5 = IndexDocumentSettings Source |