2014-05-23 4 views
1

웹 사이트에 실시간 mongodb 모니터링 통계를 표시하고 싶습니다. mongostat를 살펴 보았지만 실시간 휴식 API 또는 json 출력을 제공하지 않는 것 같습니다. mongostat에서 실시간 데이터를 검색 할 수있는 방법이 있습니까?어떻게 mongodb를 실시간으로 모니터링 할 수 있습니까?

json 파일로 stdout을 스트리밍하기 위해 일부 도구를 사용하려고 생각했지만 다른 사용자가 생각한 것 같습니다.

미리 감사드립니다.

japel는

답변

1

당신은 여기에 몇 가지 옵션을 가지고있다. 옵션으로 mongod를 실행하여 json 형식으로 일부 통계를 반환 할 수있는 http 인터페이스를 노출 할 수 있습니다. --httpinterface 옵션으로 mondod를 시작하면 인스턴스의 일부 통계가 일반 액세스 포트보다 높은 포트 1000에 노출됩니다. 그래서, 내가 실행하는 경우 : 로컬 호스트에서 MongoDB를 액세스를 얻는 외에도

mongod --httpinterface 

: 27018 : 27017은 또한 로컬 호스트에서이 HTTP 인터페이스를 얻을 수 있습니다. 사용 사례 나는 serverStatus 엔드 포인트를 타격 시도를하려는 들어

- 예를 호출 아래 상태를 반환

http://localhost:28017/serverStatus?text=1 

{ "host" : "myhost", 
    "version" : "2.6.0", 
    "process" : "mongod", 
    "pid" : { "$numberLong" : "2871" }, 
    "uptime" : 27, 
    "uptimeMillis" : { "$numberLong" : "27468" }, 
    "uptimeEstimate" : 25, 
    "localTime" : { "$date" : "2014-05-23T07:25:05.793-0700" }, 
    "asserts" : { "regular" : 0, 
    "warning" : 0, 
    "msg" : 0, 
    "user" : 0, 
    "rollovers" : 0 }, 
    "backgroundFlushing" : { "flushes" : 0, 
    "total_ms" : 0, 
    "average_ms" : 0, 
    "last_ms" : 0, 
    "last_finished" : { "$date" : "1969-12-31T16:00:00.000-0800" } }, 
    "connections" : { "current" : 0, 
    "available" : 26214, 
    "totalCreated" : { "$numberLong" : "4" } }, 
    "cursors" : { "note" : "deprecated, use server status metrics", 
    "clientCursors_size" : 0, 
    "totalOpen" : 0, 
    "pinned" : 0, 
    "totalNoTimeout" : 0, 
    "timedOut" : 0 }, 
    "dur" : { "commits" : 29, 
    "journaledMB" : 0, 
    "writeToDataFilesMB" : 0, 
    "compression" : 0, 
    "commitsInWriteLock" : 0, 
    "earlyCommits" : 0, 
    "timeMs" : { "dt" : 3013, 
     "prepLogBuffer" : 0, 
     "writeToJournal" : 0, 
     "writeToDataFiles" : 0, 
     "remapPrivateView" : 0 } }, 
    "extra_info" : { "note" : "fields vary by platform", 
    "page_faults" : 12 }, 
    "globalLock" : { "totalTime" : { "$numberLong" : "27468000" }, 
    "lockTime" : { "$numberLong" : "476591" }, 
    "currentQueue" : { "total" : 0, 
     "readers" : 0, 
     "writers" : 0 }, 
    "activeClients" : { "total" : 0, 
     "readers" : 0, 
     "writers" : 0 } }, 
    "indexCounters" : { "accesses" : 0, 
    "hits" : 0, 
    "misses" : 0, 
    "resets" : 0, 
    "missRatio" : 0 }, 
    "locks" : { "." : { "timeLockedMicros" : { "R" : { "$numberLong" : "1104" }, 
     "W" : { "$numberLong" : "476591" } }, 
     "timeAcquiringMicros" : { "R" : { "$numberLong" : "351819" }, 
     "W" : { "$numberLong" : "2178" } } }, 
    "admin" : { "timeLockedMicros" : { "r" : { "$numberLong" : "96" }, 
     "w" : { "$numberLong" : "0" } }, 
     "timeAcquiringMicros" : { "r" : { "$numberLong" : "6" }, 
     "w" : { "$numberLong" : "0" } } }, 
    "local" : { "timeLockedMicros" : { "r" : { "$numberLong" : "6082" }, 
     "w" : { "$numberLong" : "11" } }, 
     "timeAcquiringMicros" : { "r" : { "$numberLong" : "15" }, 
     "w" : { "$numberLong" : "2" } } }, 
    <LIST OF DATABASES REMOVED> 
    "network" : { "bytesIn" : 0, 
    "bytesOut" : 0, 
    "numRequests" : 0 }, 
    "opcounters" : { "insert" : 1, 
    "query" : 1, 
    "update" : 0, 
    "delete" : 0, 
    "getmore" : 0, 
    "command" : 2 }, 
    "opcountersRepl" : { "insert" : 0, 
    "query" : 0, 
    "update" : 0, 
    "delete" : 0, 
    "getmore" : 0, 
    "command" : 0 }, 
    "recordStats" : { "accessesNotInMemory" : 0, 
    "pageFaultExceptionsThrown" : 0, 
    "admin" : { "accessesNotInMemory" : 0, 
     "pageFaultExceptionsThrown" : 0 }, 
    <LIST OF DATABASES REMOVED> 
    "writeBacksQueued" : false, 
    "mem" : { "bits" : 64, 
    "resident" : 162, 
    "virtual" : 5762, 
    "supported" : true, 
    "mapped" : 1616, 
    "mappedWithJournal" : 3232 }, 
    "metrics" : { "cursor" : { "timedOut" : { "$numberLong" : "0" }, 
     "open" : { "noTimeout" : { "$numberLong" : "0" }, 
     "pinned" : { "$numberLong" : "0" }, 
     "total" : { "$numberLong" : "0" } } }, 
    "document" : { "deleted" : { "$numberLong" : "0" }, 
     "inserted" : { "$numberLong" : "1" }, 
     "returned" : { "$numberLong" : "0" }, 
     "updated" : { "$numberLong" : "0" } }, 
    "getLastError" : { "wtime" : { "num" : 0, 
     "totalMillis" : 0 }, 
     "wtimeouts" : { "$numberLong" : "0" } }, 
    "operation" : { "fastmod" : { "$numberLong" : "0" }, 
     "idhack" : { "$numberLong" : "0" }, 
     "scanAndOrder" : { "$numberLong" : "0" } }, 
    "queryExecutor" : { "scanned" : { "$numberLong" : "0" }, 
     "scannedObjects" : { "$numberLong" : "0" } }, 
    "record" : { "moves" : { "$numberLong" : "0" } }, 
    "repl" : { "apply" : { "batches" : { "num" : 0, 
      "totalMillis" : 0 }, 
     "ops" : { "$numberLong" : "0" } }, 
     "buffer" : { "count" : { "$numberLong" : "0" }, 
     "maxSizeBytes" : 268435456, 
     "sizeBytes" : { "$numberLong" : "0" } }, 
     "network" : { "bytes" : { "$numberLong" : "0" }, 
     "getmores" : { "num" : 0, 
      "totalMillis" : 0 }, 
     "ops" : { "$numberLong" : "0" }, 
     "readersCreated" : { "$numberLong" : "0" } }, 
     "preload" : { "docs" : { "num" : 0, 
      "totalMillis" : 0 }, 
     "indexes" : { "num" : 0, 
      "totalMillis" : 0 } } }, 
    "storage" : { "freelist" : { "search" : { "bucketExhausted" : { "$numberLong" : "0" }, 
      "requests" : { "$numberLong" : "0" }, 
      "scanned" : { "$numberLong" : "0" } } } }, 
    "ttl" : { "deletedDocuments" : { "$numberLong" : "0" }, 
     "passes" : { "$numberLong" : "0" } } }, 
    "ok" : 1 } 

두 번째 옵션은 mongod를위한 REST API를 inteface을 수 있도록하는 것은, 옵션은 --rest입니다. 문서는 여기에 있습니다 : http://docs.mongodb.org/ecosystem/tools/http-interfaces/. 그러나 보안 취약점을 열어 실제 사용에는 권장하지 않습니다. http://docs.mongodb.org/manual/core/security-interface/

+0

및 http 인터페이스를 활성화해도 보안 허점이 열리지 않습니다. 그것은 사실입니다. 이것은 제가 필요한 것입니다! 고맙습니다! – japel

+0

@japel 프로덕션 환경의 경우 [Best Practice] (http://docs.mongodb.org/manual/core/security-network/#nohttpinterface)는 인증을 지원하지 않으므로 MongoDB의 내장 REST 인터페이스를 비활성화 된 상태로 두는 것입니다. 이 인터페이스를 사용해야하는 경우 신뢰할 수있는 클라이언트에 대한 액세스를 제한하려고합니다. 모니터링을 위해보다 안전한 엔드 포인트를 찾는 것이 좋습니다. – Stennie

관련 문제