git.iko.soy/typeable/bloodhound
on master help sign in
Wrap up types and smoke test for stats API
commit8672b4f0791bf30e831284270c86c63274f3cfeb authorMichael Xavier <michael@michaelxavier.net> dateWed 14 Sep 2016, 18:15 (10 years ago) parent433e3bb
1 file changed+340−12
src/Database/Bloodhound/Types.hs+340−12
src/Database/Bloodhound/Types.hs+340−12
@@ -271,8 +271,12 @@ module Database.Bloodhound.Types
271271 , NodeThreadPoolsStats(..)
272272 , NodeThreadPoolStats(..)
273273 , NodeJVMStats(..)
274+ , JVMBufferPoolStats(..)
275+ , JVMGCStats(..)
276+ , JVMPoolStats(..)
274277 , NodeProcessStats(..)
275278 , NodeOSStats(..)
279+ , LoadAvgs(..)
276280 , NodeIndicesStats(..)
277281 , EsAddress(..)
278282 , PluginName(..)
@@ -3983,17 +3987,153 @@ data NodeThreadPoolStats = NodeThreadPoolStats {
39833987 , nodeThreadPoolThreads :: Int
39843988 } deriving (Eq, Show, Generic, Typeable)
39853989
3986−data NodeJVMStats = NodeJVMStats
3987− deriving (Eq, Show, Generic, Typeable)
3990+data NodeJVMStats = NodeJVMStats {
3991+ nodeJVMStatsMappedBufferPool :: JVMBufferPoolStats
3992+ , nodeJVMStatsDirectBufferPool :: JVMBufferPoolStats
3993+ , nodeJVMStatsGCOldCollector :: JVMGCStats
3994+ , nodeJVMStatsGCYoungCollector :: JVMGCStats
3995+ , nodeJVMStatsPeakThreadsCount :: Int
3996+ , nodeJVMStatsThreadsCount :: Int
3997+ , nodeJVMStatsOldPool :: JVMPoolStats
3998+ , nodeJVMStatsSurvivorPool :: JVMPoolStats
3999+ , nodeJVMStatsYoungPool :: JVMPoolStats
4000+ , nodeJVMStatsNonHeapCommitted :: Bytes
4001+ , nodeJVMStatsNonHeapUsed :: Bytes
4002+ , nodeJVMStatsHeapMax :: Bytes
4003+ , nodeJVMStatsHeapCommitted :: Bytes
4004+ , nodeJVMStatsHeapUsedPercent :: Int
4005+ , nodeJVMStatsHeapUsed :: Bytes
4006+ , nodeJVMStatsUptime :: NominalDiffTime
4007+ , nodeJVMStatsTimestamp :: UTCTime
4008+ } deriving (Eq, Show, Generic, Typeable)
4009+
4010+data JVMBufferPoolStats = JVMBufferPoolStats {
4011+ jvmBufferPoolStatsTotalCapacity :: Bytes
4012+ , jvmBufferPoolStatsUsed :: Bytes
4013+ , jvmBufferPoolStatsCount :: Int
4014+ } deriving (Eq, Show, Generic, Typeable)
4015+
4016+data JVMGCStats = JVMGCStats {
4017+ jvmGCStatsCollectionTime :: NominalDiffTime
4018+ , jvmGCStatsCollectionCount :: Int
4019+ } deriving (Eq, Show, Generic, Typeable)
4020+
4021+data JVMPoolStats = JVMPoolStats {
4022+ jvmPoolStatsPeakMax :: Bytes
4023+ , jvmPoolStatsPeakUsed :: Bytes
4024+ , jvmPoolStatsMax :: Bytes
4025+ , jvmPoolStatsUsed :: Bytes
4026+ } deriving (Eq, Show, Generic, Typeable)
39884027
3989−data NodeProcessStats = NodeProcessStats
3990− deriving (Eq, Show, Generic, Typeable)
4028+data NodeProcessStats = NodeProcessStats {
4029+ nodeProcessMemTotalVirtual :: Bytes
4030+ , nodeProcessMemShare :: Bytes
4031+ , nodeProcessMemResident :: Bytes
4032+ , nodeProcessCPUTotal :: NominalDiffTime
4033+ , nodeProcessCPUUser :: NominalDiffTime
4034+ , nodeProcessCPUSys :: NominalDiffTime
4035+ , nodeProcessCPUPercent :: Int
4036+ , nodeProcessOpenFDs :: Int
4037+ , nodeProcessTimestamp :: UTCTime
4038+ } deriving (Eq, Show, Generic, Typeable)
39914039
3992−data NodeOSStats = NodeOSStats
3993− deriving (Eq, Show, Generic, Typeable)
4040+data NodeOSStats = NodeOSStats {
4041+ nodeOSSwapFree :: Bytes
4042+ , nodeOSSwapUsed :: Bytes
4043+ , nodeOSMemActualUsed :: Bytes
4044+ , nodeOSMemActualFree :: Bytes
4045+ , nodeOSMemUsedPercent :: Int
4046+ , nodeOSMemFreePercent :: Int
4047+ , nodeOSMemUsed :: Bytes
4048+ , nodeOSMemFree :: Bytes
4049+ , nodeOSCPUStolen :: Int
4050+ , nodeOSCPUUsage :: Int
4051+ , nodeOSCPUIdle :: Int
4052+ , nodeOSCPUUser :: Int
4053+ , nodeOSCPUSys :: Int
4054+ , nodeOSLoad :: LoadAvgs
4055+ , nodeOSUptime :: NominalDiffTime
4056+ , nodeOSTimestamp :: UTCTime
4057+ } deriving (Eq, Show, Generic, Typeable)
39944058
3995−data NodeIndicesStats = NodeIndicesStats
3996− deriving (Eq, Show, Generic, Typeable)
4059+data LoadAvgs = LoadAvgs {
4060+ loadAvg1Min :: Double
4061+ , loadAvg5Min :: Double
4062+ , loadAvg15Min :: Double
4063+ } deriving (Eq, Show, Generic, Typeable)
4064+
4065+data NodeIndicesStats = NodeIndicesStats {
4066+ nodeIndicesStatsRecoveryThrottleTime :: NominalDiffTime
4067+ , nodeIndicesStatsRecoveryCurrentAsTarget :: Int
4068+ , nodeIndicesStatsRecoveryCurrentAsSource :: Int
4069+ , nodeIndicesStatsQueryCacheMisses :: Int
4070+ , nodeIndicesStatsQueryCacheHits :: Int
4071+ , nodeIndicesStatsQueryCacheEvictions :: Int
4072+ , nodeIndicesStatsQueryCacheSize :: Bytes
4073+ , nodeIndicesStatsSuggestCurrent :: Int
4074+ , nodeIndicesStatsSuggestTime :: NominalDiffTime
4075+ , nodeIndicesStatsSuggestTotal :: Int
4076+ , nodeIndicesStatsTranslogSize :: Bytes
4077+ , nodeIndicesStatsTranslogOps :: Int
4078+ , nodeIndicesStatsSegFixedBitSetMemory :: Bytes
4079+ , nodeIndicesStatsSegVersionMapMemory :: Bytes
4080+ , nodeIndicesStatsSegIndexWriterMaxMemory :: Bytes
4081+ , nodeIndicesStatsSegIndexWriterMemory :: Bytes
4082+ , nodeIndicesStatsSegMemory :: Bytes
4083+ , nodeIndicesStatsSegCount :: Int
4084+ , nodeIndicesStatsCompletionSize :: Bytes
4085+ , nodeIndicesStatsPercolateQueries :: Int
4086+ , nodeIndicesStatsPercolateMemory :: Bytes
4087+ , nodeIndicesStatsPercolateCurrent :: Int
4088+ , nodeIndicesStatsPercolateTime :: NominalDiffTime
4089+ , nodeIndicesStatsPercolateTotal :: Int
4090+ , nodeIndicesStatsFieldDataEvictions :: Int
4091+ , nodeIndicesStatsFieldDataMemory :: Bytes
4092+ , nodeIndicesStatsIDCacheMemory :: Bytes
4093+ , nodeIndicesStatsFilterCacheEvictions :: Int
4094+ , nodeIndicesStatsFilterCacheMemory :: Bytes
4095+ , nodeIndicesStatsWarmerTotalTime :: NominalDiffTime
4096+ , nodeIndicesStatsWarmerTotal :: Int
4097+ , nodeIndicesStatsWarmerCurrent :: Int
4098+ , nodeIndicesStatsFlushTotalTime :: NominalDiffTime
4099+ , nodeIndicesStatsFlushTotal :: Int
4100+ , nodeIndicesStatsRefreshTotalTime :: NominalDiffTime
4101+ , nodeIndicesStatsRefreshTotal :: Int
4102+ , nodeIndicesStatsMergesTotalSize :: Bytes
4103+ , nodeIndicesStatsMergesTotalDocs :: Int
4104+ , nodeIndicesStatsMergesTotalTime :: NominalDiffTime
4105+ , nodeIndicesStatsMergesTotal :: Int
4106+ , nodeIndicesStatsMergesCurrentSize :: Bytes
4107+ , nodeIndicesStatsMergesCurrentDocs :: Int
4108+ , nodeIndicesStatsMergesCurrent :: Int
4109+ , nodeIndicesStatsSearchFetchCurrent :: Int
4110+ , nodeIndicesStatsSearchFetchTime :: NominalDiffTime
4111+ , nodeIndicesStatsSearchFetchTotal :: Int
4112+ , nodeIndicesStatsSearchQueryCurrent :: Int
4113+ , nodeIndicesStatsSearchQueryTime :: NominalDiffTime
4114+ , nodeIndicesStatsSearchQueryTotal :: Int
4115+ , nodeIndicesStatsSearchOpenContexts :: Int
4116+ , nodeIndicesStatsGetCurrent :: Int
4117+ , nodeIndicesStatsGetMissingTime :: NominalDiffTime
4118+ , nodeIndicesStatsGetMissingTotal :: Int
4119+ , nodeIndicesStatsGetExistsTime :: NominalDiffTime
4120+ , nodeIndicesStatsGetExistsTotal :: Int
4121+ , nodeIndicesStatsGetTime :: NominalDiffTime
4122+ , nodeIndicesStatsGetTotal :: Int
4123+ , nodeIndicesStatsIndexingThrottleTime :: NominalDiffTime
4124+ , nodeIndicesStatsIndexingIsThrottled :: Bool
4125+ , nodeIndicesStatsIndexingNoopUpdateTotal :: Int
4126+ , nodeIndicesStatsIndexingDeleteCurrent :: Int
4127+ , nodeIndicesStatsIndexingDeleteTime :: NominalDiffTime
4128+ , nodeIndicesStatsIndexingDeleteTotal :: Int
4129+ , nodeIndicesStatsIndexingIndexCurrent :: Int
4130+ , nodeIndicesStatsIndexingIndexTime :: NominalDiffTime
4131+ , nodeIndicesStatsIndexingTotal :: Int
4132+ , nodeIndicesStatsStoreThrottleTime :: NominalDiffTime
4133+ , nodeIndicesStatsStoreSize :: Bytes
4134+ , nodeIndicesStatsDocsDeleted :: Int
4135+ , nodeIndicesStatsDocsCount :: Int
4136+ } deriving (Eq, Show, Generic, Typeable)
39974137
39984138-- | A quirky address format used throughout ElasticSearch. An example
39994139-- would be inet[/1.1.1.1:9200]. inet may be a placeholder for a
@@ -4636,16 +4776,204 @@ instance FromJSON NodeThreadPoolStats where
46364776 <*> o .: "threads"
46374777
46384778instance FromJSON NodeJVMStats where
4639− parseJSON _ = pure NodeJVMStats
4779+ parseJSON = withObject "NodeJVMStats" parse
4780+ where
4781+ parse o = do
4782+ bufferPools <- o .: "buffer_pools"
4783+ mapped <- bufferPools .: "mapped"
4784+ direct <- bufferPools .: "direct"
4785+ gc <- o .: "gc"
4786+ collectors <- gc .: "collectors"
4787+ oldC <- collectors .: "old"
4788+ youngC <- collectors .: "young"
4789+ threads <- o .: "threads"
4790+ mem <- o .: "mem"
4791+ pools <- mem .: "pools"
4792+ oldM <- pools .: "old"
4793+ survivorM <- pools .: "survivor"
4794+ youngM <- pools .: "young"
4795+ NodeJVMStats <$> pure mapped
4796+ <*> pure direct
4797+ <*> pure oldC
4798+ <*> pure youngC
4799+ <*> threads .: "peak_count"
4800+ <*> threads .: "count"
4801+ <*> pure oldM
4802+ <*> pure survivorM
4803+ <*> pure youngM
4804+ <*> mem .: "non_heap_committed_in_bytes"
4805+ <*> mem .: "non_heap_used_in_bytes"
4806+ <*> mem .: "heap_max_in_bytes"
4807+ <*> mem .: "heap_committed_in_bytes"
4808+ <*> mem .: "heap_used_percent"
4809+ <*> mem .: "heap_used_in_bytes"
4810+ <*> (unMS <$> o .: "uptime_in_millis")
4811+ <*> (posixMS <$> o .: "timestamp")
4812+
4813+instance FromJSON JVMBufferPoolStats where
4814+ parseJSON = withObject "JVMBufferPoolStats" parse
4815+ where
4816+ parse o = JVMBufferPoolStats <$> o .: "total_capacity_in_bytes"
4817+ <*> o .: "used_in_bytes"
4818+ <*> o .: "count"
4819+
4820+instance FromJSON JVMGCStats where
4821+ parseJSON = withObject "JVMGCStats" parse
4822+ where
4823+ parse o = JVMGCStats <$> (unMS <$> o .: "collection_time_in_millis")
4824+ <*> o .: "collection_count"
4825+
4826+instance FromJSON JVMPoolStats where
4827+ parseJSON = withObject "JVMPoolStats" parse
4828+ where
4829+ parse o = JVMPoolStats <$> o .: "peak_max_in_bytes"
4830+ <*> o .: "peak_used_in_bytes"
4831+ <*> o .: "max_in_bytes"
4832+ <*> o .: "used_in_bytes"
46404833
46414834instance FromJSON NodeProcessStats where
4642− parseJSON _ = pure NodeProcessStats
4835+ parseJSON = withObject "NodeProcessStats" parse
4836+ where
4837+ parse o = do
4838+ mem <- o .: "mem"
4839+ cpu <- o .: "cpu"
4840+ NodeProcessStats <$> mem .: "total_virtual_in_bytes"
4841+ <*> mem .: "share_in_bytes"
4842+ <*> mem .: "resident_in_bytes"
4843+ <*> (unMS <$> cpu .: "total_in_millis")
4844+ <*> (unMS <$> cpu .: "user_in_millis")
4845+ <*> (unMS <$> cpu .: "sys_in_millis")
4846+ <*> cpu .: "percent"
4847+ <*> o .: "open_file_descriptors"
4848+ <*> (posixMS <$> o .: "timestamp")
46434849
46444850instance FromJSON NodeOSStats where
4645− parseJSON _ = pure NodeOSStats
4851+ parseJSON = withObject "NodeOSStats" parse
4852+ where
4853+ parse o = do
4854+ swap <- o .: "swap"
4855+ mem <- o .: "mem"
4856+ cpu <- o .: "cpu"
4857+ load <- o .: "load_average"
4858+ NodeOSStats <$> swap .: "free_in_bytes"
4859+ <*> swap .: "used_in_bytes"
4860+ <*> mem .: "actual_used_in_bytes"
4861+ <*> mem .: "actual_free_in_bytes"
4862+ <*> mem .: "used_percent"
4863+ <*> mem .: "free_percent"
4864+ <*> mem .: "used_in_bytes"
4865+ <*> mem .: "free_in_bytes"
4866+ <*> cpu .: "stolen"
4867+ <*> cpu .: "usage"
4868+ <*> cpu .: "idle"
4869+ <*> cpu .: "user"
4870+ <*> cpu .: "sys"
4871+ <*> pure load
4872+ <*> (unMS <$> o .: "uptime_in_millis")
4873+ <*> (posixMS <$> o .: "timestamp")
4874+
4875+instance FromJSON LoadAvgs where
4876+ parseJSON = withArray "LoadAvgs" parse
4877+ where
4878+ parse v = case V.toList v of
4879+ [one, five, fifteen] -> LoadAvgs <$> parseJSON one
4880+ <*> parseJSON five
4881+ <*> parseJSON fifteen
4882+ _ -> fail "Expecting a triple of Doubles"
46464883
46474884instance FromJSON NodeIndicesStats where
4648− parseJSON _ = pure NodeIndicesStats
4885+ parseJSON = withObject "NodeIndicesStats" parse
4886+ where
4887+ parse o = do
4888+ recovery <- o .: "recovery"
4889+ queryCache <- o .: "query_cache"
4890+ suggest <- o .: "suggest"
4891+ translog <- o .: "translog"
4892+ segments <- o .: "segments"
4893+ completion <- o .: "completion"
4894+ percolate <- o .: "percolate"
4895+ fielddata <- o .: "fielddata"
4896+ idCache <- o .: "id_cache"
4897+ filterCache <- o .: "filter_cache"
4898+ warmer <- o .: "warmer"
4899+ flush <- o .: "flush"
4900+ refresh <- o .: "refresh"
4901+ merges <- o .: "merges"
4902+ search <- o .: "search"
4903+ getStats <- o .: "get"
4904+ indexing <- o .: "indexing"
4905+ store <- o .: "store"
4906+ docs <- o .: "docs"
4907+ NodeIndicesStats <$> (unMS <$> recovery .: "throttle_time_in_millis")
4908+ <*> recovery .: "current_as_target"
4909+ <*> recovery .: "current_as_source"
4910+ <*> queryCache .: "miss_count"
4911+ <*> queryCache .: "hit_count"
4912+ <*> queryCache .: "evictions"
4913+ <*> queryCache .: "memory_size_in_bytes"
4914+ <*> suggest .: "current"
4915+ <*> (unMS <$> suggest .: "time_in_millis")
4916+ <*> suggest .: "total"
4917+ <*> translog .: "size_in_bytes"
4918+ <*> translog .: "operations"
4919+ <*> segments .: "fixed_bit_set_memory_in_bytes"
4920+ <*> segments .: "version_map_memory_in_bytes"
4921+ <*> segments .: "index_writer_max_memory_in_bytes"
4922+ <*> segments .: "index_writer_memory_in_bytes"
4923+ <*> segments .: "memory_in_bytes"
4924+ <*> segments .: "count"
4925+ <*> completion .: "size_in_bytes"
4926+ <*> percolate .: "queries"
4927+ <*> percolate .: "memory_size_in_bytes"
4928+ <*> percolate .: "current"
4929+ <*> (unMS <$> percolate .: "time_in_millis")
4930+ <*> percolate .: "total"
4931+ <*> fielddata .: "evictions"
4932+ <*> fielddata .: "memory_size_in_bytes"
4933+ <*> idCache .: "memory_size_in_bytes"
4934+ <*> filterCache .: "evictions"
4935+ <*> filterCache .: "memory_size_in_bytes"
4936+ <*> (unMS <$> warmer .: "total_time_in_millis")
4937+ <*> warmer .: "total"
4938+ <*> warmer .: "current"
4939+ <*> (unMS <$> flush .: "total_time_in_millis")
4940+ <*> flush .: "total"
4941+ <*> (unMS <$> refresh .: "total_time_in_millis")
4942+ <*> refresh .: "total"
4943+ <*> merges .: "total_size_in_bytes"
4944+ <*> merges .: "total_docs"
4945+ <*> (unMS <$> merges .: "total_time_in_millis")
4946+ <*> merges .: "total"
4947+ <*> merges .: "current_size_in_bytes"
4948+ <*> merges .: "current_docs"
4949+ <*> merges .: "current"
4950+ <*> search .: "fetch_current"
4951+ <*> (unMS <$> search .: "fetch_time_in_millis")
4952+ <*> search .: "fetch_total"
4953+ <*> search .: "query_current"
4954+ <*> (unMS <$> search .: "query_time_in_millis")
4955+ <*> search .: "query_total"
4956+ <*> search .: "open_contexts"
4957+ <*> getStats .: "current"
4958+ <*> (unMS <$> getStats .: "missing_time_in_millis")
4959+ <*> getStats .: "missing_total"
4960+ <*> (unMS <$> getStats .: "exists_time_in_millis")
4961+ <*> getStats .: "exists_total"
4962+ <*> (unMS <$> getStats .: "time_in_millis")
4963+ <*> getStats .: "total"
4964+ <*> (unMS <$> indexing .: "throttle_time_in_millis")
4965+ <*> indexing .: "is_throttled"
4966+ <*> indexing .: "noop_update_total"
4967+ <*> indexing .: "delete_current"
4968+ <*> (unMS <$> indexing .: "delete_time_in_millis")
4969+ <*> indexing .: "delete_total"
4970+ <*> indexing .: "index_current"
4971+ <*> (unMS <$> indexing .: "index_time_in_millis")
4972+ <*> indexing .: "index_total"
4973+ <*> (unMS <$> store .: "throttle_time_in_millis")
4974+ <*> store .: "size_in_bytes"
4975+ <*> docs .: "deleted"
4976+ <*> docs .: "count"
46494977
46504978instance FromJSON NodeBreakersStats where
46514979 parseJSON = withObject "NodeBreakersStats" parse