溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

elasticsearch的site插件怎么使用

發(fā)布時(shí)間:2021-12-16 10:09:41 來源:億速云 閱讀:205 作者:iii 欄目:云計(jì)算

這篇文章主要介紹“elasticsearch的site插件怎么使用”,在日常操作中,相信很多人在elasticsearch的site插件怎么使用問題上存在疑惑,小編查閱了各式資料,整理出簡(jiǎn)單好用的操作方法,希望對(duì)大家解答”elasticsearch的site插件怎么使用”的疑惑有所幫助!接下來,請(qǐng)跟著小編一起來學(xué)習(xí)吧!

        現(xiàn)在我們用 bootstrap+angularJs 來寫一個(gè)簡(jiǎn)單的頁面,一個(gè)site插件,它通過我們前面開發(fā)的translogRest插件訪問操作日志,并且展示。

<!doctype html>
<html ng-app='app' ng-controller="translogCtrl">
    <head>
        <script src="lib/angular.js"></script>
        <link rel="stylesheet" type="text/css" href="lib/Pretty-JSON/pretty_json.css">
        <link rel="stylesheet" href="http://cdn.bootcss.com/twitter-bootstrap/3.0.3/css/bootstrap.min.css">
				<link rel="stylesheet" href="http://cdn.bootcss.com/twitter-bootstrap/3.0.3/css/bootstrap-theme.min.css">
				<script src="http://cdn.bootcss.com/jquery/1.10.2/jquery.min.js"></script>
				<script src="http://cdn.bootcss.com/twitter-bootstrap/3.0.3/js/bootstrap.min.js"></script>
				<script src="lib/Pretty-JSON/pretty_json.js" type="text/javascript"></script>
				<script src="translog.js"></script>        
    </head>
    <body>
    	 <nav class="navbar navbar navbar-inverse" role="navigation">
			  <div class="container-fluid">
			    <div class="navbar-header">
			      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
			        <span class="sr-only">Toggle navigation</span>
			        <span class="icon-bar"></span>
			        <span class="icon-bar"></span>
			        <span class="icon-bar"></span>
			      </button>
			      <a class="navbar-brand" href="#">操作日志</a>
			    </div>
			    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
			      <ul class="nav navbar-nav">
			        <li class="active"><a href="#">創(chuàng)建</a></li>
			        <li><a href="#">保存</a></li>
			        <li><a href="#">刪除</a></li>
			      </ul>
			      <form class="navbar-form navbar-left" role="search">
			        <div class="form-group">
			          <input type="text" ng-model="file"  class="form-control" placeholder="日志路徑">
			          <button type="button" class="btn btn-primary " ng-click="getData()">查看</button>
			        </div>
			      </form>
			    </div>
			  </div>
			</nav>
       <table class="table table-hover">
        <thead>
          <tr>
            <th>操作類型</th>
            <th>版本</th>
            <th>類型</th>
            <th>路由</th>
            <th>父類</th>
            <th>TTL</th>
            <th>時(shí)間</th>
            <th>操作</th>
          </tr>
        </thead>
        <tbody>
          <tr ng-repeat="item in itemList">
            <td><span class="label label-primary">{{item.opType}}</span></td>
            <td><span class="badge">{{item.version}}</span></td>
            <td>{{item.type}}</td>
            <td>{{item.routing}}</td>
            <td>{{item.parent}}</td>
            <td>{{item.ttl}}</td>
            <td>{{item.timestamp | date:'yyyy-MM-dd HH:mm'}}</td>
            <td>
            	<button type="button" class="btn btn-success" ng-click="view($index)">查看</button>
            </td>
          </tr>
        </tbody>
      </table>
      <div class="modal fade" id="editPanel">
			  <div class="modal-dialog">
			    <div class="modal-content">
			      <div class="modal-header">
			        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			        <h5 class="modal-title">ID:{{editItem.id}}</h5>
			      </div>
			      <div class="modal-body">
			        <div id="prettyJson"></div>
			      </div>
			      <div class="modal-footer">
			        <button type="button" class="btn btn-default" data-dismiss="modal">關(guān)閉</button>
			      </div>
			    </div>
			  </div>
			</div>
    </body>
</html>
var module = angular.module('app', []);
function translogCtrl($scope, $http) {
	$scope.getData = function() {
		var file = $scope.file;
		$http.get('http://localhost:9200/_translog', {
			params : {
				file : file,
				size : 12
			}
		}).success(function(data, status, headers, config) {
			$scope.itemList = data;
			$scope.view = function(id) {
				var item = $scope.itemList[id];
				$scope.editItem = item;

				try {
					$('#prettyJson').html( pretty.parse (eval("(" + item.source + ")")));
				}
				catch (error) {
					$('#prettyJson').html(pretty.error (error));
				}

				$('#editPanel').modal('show');

			}
		}).error(function(data, status, headers, config) {
			console.info(data);
		});
	}
}

然后我們復(fù)制應(yīng)用到 plugins\translogView\_site 下面就可以了。我們也可以補(bǔ)充插件描述文件_site\es-plugin.properties

description=view translog

瀏覽器里輸入 

http://localhost:9200/_nodes?all=true

可以看到我們的插件已經(jīng)安裝成功,描述信息也有了。

elasticsearch的site插件怎么使用

到此,關(guān)于“elasticsearch的site插件怎么使用”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識(shí),請(qǐng)繼續(xù)關(guān)注億速云網(wǎng)站,小編會(huì)繼續(xù)努力為大家?guī)砀鄬?shí)用的文章!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI